T
- the command interfacepublic class JCommanderWrapper<T> extends Object implements CommandBuilder<T>
JCommander
object into @Inject
field of each command @Parameter(help=true)
fields Constructor and Description |
---|
JCommanderWrapper(String programName,
Object command)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
JCommanderWrapper<T> |
addCommand(String name,
T command)
Adds a leaf command with explicit name.
|
JCommanderWrapper<T> |
addCommand(T command)
Adds a leaf command.
|
JCommanderWrapper<T> |
addGroup(String name,
T command,
Consumer<? super CommandBuilder<T>> configurator)
Adds a group with explicit name.
|
JCommanderWrapper<T> |
addGroup(T command,
Consumer<? super CommandBuilder<T>> configurator)
Adds a group.
|
JCommanderWrapper<T> |
configure(Consumer<? super CommandBuilder<T>> configurator)
Configures this object.
|
static void |
handle(com.beust.jcommander.ParameterException exception,
Consumer<? super String> sink)
Handles
ParameterException of JCommander. |
Optional<T> |
parse(String... args)
Parses the program arguments and returns the corresponded command object.
|
public JCommanderWrapper<T> configure(Consumer<? super CommandBuilder<T>> configurator)
configure
in interface CommandBuilder<T>
configurator
- the configuratorpublic JCommanderWrapper<T> addCommand(T command)
CommandBuilder
addCommand
in interface CommandBuilder<T>
command
- the command objectpublic JCommanderWrapper<T> addCommand(String name, T command)
CommandBuilder
addCommand
in interface CommandBuilder<T>
name
- the command namecommand
- the command objectpublic JCommanderWrapper<T> addGroup(T command, Consumer<? super CommandBuilder<T>> configurator)
CommandBuilder
addGroup
in interface CommandBuilder<T>
command
- the group commandconfigurator
- the group configuratorpublic JCommanderWrapper<T> addGroup(String name, T command, Consumer<? super CommandBuilder<T>> configurator)
CommandBuilder
addGroup
in interface CommandBuilder<T>
name
- the group namecommand
- the group commandconfigurator
- the group configuratorpublic Optional<T> parse(String... args)
args
- the program argumentsempty
if there are no commands to execute (e.g. help)com.beust.jcommander.ParameterException
- if arguments are not validCopyright © 2011–2019 Asakusa Framework Team. All rights reserved.