Interface CLI
public interface CLI
Interface defining a command-line interface (in other words a command such as 'run', 'ls'...).
This interface is polyglot to ease reuse such as in Vert.x Shell.
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.- Author:
- Clement Escoffier invalid input: '<'[email protected]>
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionaddArgument(Argument arg) Adds an argument.addArguments(List<Argument> args) Adds a set of arguments.Adds an option.addOptions(List<Option> options) Adds a set of options.static CLICreates an instance ofCLIfrom the given Java class.static CLICreates an instance ofCLIusing the default implementation.getArgument(int index) Gets anArgumentbased on its index.getArgument(String name) Gets anArgumentbased on its name (argument name).Gets the list of defined arguments.getName()Gets anOptionbased on its name (short name, long name or argument name).Gets the list of options.intbooleanisHidden()Checks whether or not the currentCLIinstance is hidden.Parses the user command line interface and create a newCommandLinecontaining extracting values.Parses the user command line interface and create a newCommandLinecontaining extracting values.removeArgument(int index) Removes an argument identified by its index.removeOption(String name) Removes an option identified by its name.setArguments(List<Argument> args) Sets the list of arguments.setDescription(String desc) setHidden(boolean hidden) Sets whether or not the current instance ofCLImust be hidden.Sets the name of the CLI.setOptions(List<Option> options) Sets the list of arguments.setPriority(int priority) Sets the priority of the CLI.setSummary(String summary) Sets the summary of the CLI.usage(StringBuilder builder) Generates the usage / help of the currentCLI.usage(StringBuilder builder, String prefix) Generates the usage / help of the currentCLI.
-
Method Details
-
create
-
create
-
parse
Parses the user command line interface and create a newCommandLinecontaining extracting values.- Parameters:
arguments- the arguments- Returns:
- the creates command line
-
parse
Parses the user command line interface and create a newCommandLinecontaining extracting values.- Parameters:
arguments- the argumentsvalidate- enable / disable parsing validation- Returns:
- the creates command line
-
getName
String getName()- Returns:
- the CLI name.
-
setName
-
getDescription
String getDescription()- Returns:
- the CLI description.
-
setDescription
-
getSummary
String getSummary()- Returns:
- the CLI summary.
-
setSummary
-
isHidden
-
setHidden
-
getOptions
-
addOption
-
addOptions
Adds a set of options. UnlikesetOptions(List)}, this method does not remove the existing options. The given list is appended to the existing list.- Parameters:
options- the options, must not benull- Returns:
- the current
CLIinstance
-
setOptions
-
getArguments
-
addArgument
-
addArguments
Adds a set of arguments. UnlikesetArguments(List), this method does not remove the existing arguments. The given list is appended to the existing list.- Parameters:
args- the arguments, must not benull- Returns:
- the current
CLIinstance
-
setArguments
-
getOption
-
getArgument
-
getArgument
-
removeOption
-
removeArgument
-
usage
-
usage
-
getPriority
int getPriority()- Returns:
- the CLI priority.
-
setPriority
-