A command line interface has a name, and defines a set of options and arguments. Options are key-value pair such
as -foo=bar or -flag. The supported formats depend on the used parser. Arguments are unlike
options raw values. Options are defined using
Option, while argument are defined using Argument.
Command line interfaces also define a summary and a description. These attributes are used in the usage generation
. To disable the help generation, set the hidden attribute to true.
Command Line Interface object does not contains "value", it's a model. It must be evaluated by a
parser that returns a CommandLine object containing the argument and option values.
Argument, Option
| Modifier and Type | Method and Description |
|---|---|
| public CLI | Returns: the currentCLI instancethe argument, must not be arg)nullAdds an argument. |
| public CLI | Returns: the currentCLI instancethe arguments, must not be args)nullAdds a set of arguments. |
| public CLI | |
| public CLI | Returns: the currentCLI instancethe options, must not be options)nullAdds a set of options. |
| public static CLI | |
| public static CLI | |
| public @Nullable Argument | getArgument(String
the name of the argument, must not be name)nullGets an |
| public @Nullable Argument | |
| public List | |
| public @Nullable String | |
| public String | |
| public @Nullable Option | |
| public List | |
| public int | |
| public @Nullable String | |
| public boolean | |
| public CommandLine | Returns: the creates command linethe arguments arguments)Parses the user command line interface and create a new |
| public CommandLine | Returns: the creates command linethe arguments arguments, boolean enable / disable parsing validation validate)Parses the user command line interface and create a new |
| public CLI | Returns: the currentCLI instancethe argument index index)Removes an argument identified by its index. |
| public CLI | Returns: the currentCLI instancethe option name name)Removes an option identified by its name. |
| public CLI | Returns: the currentCLI instancethe list of arguments, must not be args)nullSets the list of arguments. |
| public CLI | |
| public CLI | |
| public CLI | |
| public CLI | Returns: the currentCLI instancethe list of options, must not be options)nullSets the list of arguments. |
| public CLI | |
| public CLI | |
| public CLI | Returns: the currentCLI instancethe string builder in which the help is going to be printed builder)Generates the usage / help of the current |
| public CLI | Returns: the currentCLI instancethe string builder in which the help is going to be printed builder, String an optional prefix prefix)Generates the usage / help of the current |
| addArgument | back to summary |
|---|---|
| public CLI addArgument(Argument arg) Adds an argument. | |
| addArguments | back to summary |
|---|---|
| public CLI addArguments(List<Argument> args) Adds a set of arguments. Unlike | |
| addOption | back to summary |
|---|---|
| public CLI addOption(Option option) Adds an option. | |
| addOptions | back to summary |
|---|---|
| public CLI addOptions(List<Option> options) Adds a set of options. Unlike | |
| create | back to summary |
|---|---|
| public static CLI create(String name) Creates an instance of | |
| create | back to summary |
|---|---|
| public static CLI create(Class<?> clazz) Creates an instance of | |
| getArgument | back to summary |
|---|---|
| public @Nullable Argument getArgument(String name) Gets an | |
| getArgument | back to summary |
|---|---|
| public @Nullable Argument getArgument(int index) Gets an | |
| getArguments | back to summary |
|---|---|
| public List Gets the list of defined arguments. | |
| getDescription | back to summary |
|---|---|
| public @Nullable String getDescription() | |
| getName | back to summary |
|---|---|
public String getName()
| |
| getOption | back to summary |
|---|---|
| public @Nullable Option getOption(String name) Gets an | |
| getOptions | back to summary |
|---|---|
| public List Gets the list of options. | |
| getPriority | back to summary |
|---|---|
public int getPriority()
| |
| getSummary | back to summary |
|---|---|
| public @Nullable String getSummary() | |
| isHidden | back to summary |
|---|---|
| public boolean isHidden() Checks whether or not the current | |
| parse | back to summary |
|---|---|
| public CommandLine parse(List<String> arguments) Parses the user command line interface and create a new
| |
| parse | back to summary |
|---|---|
| public CommandLine parse(List<String> arguments, boolean validate) Parses the user command line interface and create a new
| |
| removeArgument | back to summary |
|---|---|
| public CLI removeArgument(int index) Removes an argument identified by its index. This method does nothing if the argument cannot be found. | |
| removeOption | back to summary |
|---|---|
| public CLI removeOption(String name) Removes an option identified by its name. This method does nothing if the option cannot be found. | |
| setArguments | back to summary |
|---|---|
| public CLI setArguments(List<Argument> args) Sets the list of arguments. | |
| setDescription | back to summary |
|---|---|
public CLI setDescription(String desc)
| |
| setHidden | back to summary |
|---|---|
| public CLI setHidden(boolean hidden) Sets whether or not the current instance of | |
| setName | back to summary |
|---|---|
| public CLI setName(String name) Sets the name of the CLI. | |
| setOptions | back to summary |
|---|---|
| public CLI setOptions(List<Option> options) Sets the list of arguments. | |
| setPriority | back to summary |
|---|---|
| public CLI setPriority(int priority) Sets the priority of the CLI. | |
| setSummary | back to summary |
|---|---|
| public CLI setSummary(String summary) Sets the summary of the CLI. | |
| usage | back to summary |
|---|---|
| public CLI usage(StringBuilder builder) Generates the usage / help of the current
| |
| usage | back to summary |
|---|---|
| public CLI usage(StringBuilder builder, String prefix) Generates the usage / help of the current
| |