new 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
Methods
-
addArgument(arg) → {CLI}
-
Adds an argument.
Parameters:
Name Type Description argObject the argument, must not be nullReturns:
the current CLI instance- Type
- CLI
-
addArguments(args) → {CLI}
-
Adds a set of arguments. Unlike CLI#setArguments, this method does not remove the existing arguments. The given list is appended to the existing list.
Parameters:
Name Type Description argsArray.<Object> the arguments, must not be nullReturns:
the current CLI instance- Type
- CLI
-
addOption(option) → {CLI}
-
Adds an option.
Parameters:
Name Type Description optionObject the option, must not be null.Returns:
the current CLI instance- Type
- CLI
-
addOptions(options) → {CLI}
-
Adds a set of options. Unlike CLI#setOptions}, this method does not remove the existing options. The given list is appended to the existing list.
Parameters:
Name Type Description optionsArray.<Object> the options, must not be nullReturns:
the current CLI instance- Type
- CLI
-
getArgument(index) → {Object}
-
Gets an Argument based on its index.
Parameters:
Name Type Description indexnumber the index, must be positive or zero. Returns:
the Argument,nullif not found.- Type
- Object
-
getArguments() → {Array.<Object>}
-
Gets the list of defined arguments.
Returns:
the list of argument, empty if none.- Type
- Array.<Object>
-
getDescription() → {string}
-
Returns:
-
the CLI description.
-
- Type
- string
-
-
getName() → {string}
-
Returns:
-
the CLI name.
-
- Type
- string
-
-
getOption(name) → {Object}
-
Gets an Option based on its name (short name, long name or argument name).
Parameters:
Name Type Description namestring the name, must not be nullReturns:
the Option,nullif not found- Type
- Object
-
getOptions() → {Array.<Object>}
-
Gets the list of options.
Returns:
the list of options, empty if none.- Type
- Array.<Object>
-
getSummary() → {string}
-
Returns:
-
the CLI summary.
-
- Type
- string
-
-
isHidden() → {boolean}
-
Checks whether or not the current CLI instance is hidden.
Returns:
trueif the current CLI is hidden, otherwise- Type
- boolean
-
parse(arguments, validate) → {CommandLine}
-
Parses the user command line interface and create a new CommandLine containing extracting values.
Parameters:
Name Type Description argumentsArray.<string> the arguments validateboolean enable / disable parsing validation Returns:
the creates command line- Type
- CommandLine
-
removeArgument(index) → {CLI}
-
Removes an argument identified by its index. This method does nothing if the argument cannot be found.
Parameters:
Name Type Description indexnumber the argument index Returns:
the current CLI instance- Type
- CLI
-
removeOption(name) → {CLI}
-
Removes an option identified by its name. This method does nothing if the option cannot be found.
Parameters:
Name Type Description namestring the option name Returns:
the current CLI instance- Type
- CLI
-
setArguments(args) → {CLI}
-
Sets the list of arguments.
Parameters:
Name Type Description argsArray.<Object> the list of arguments, must not be nullReturns:
the current CLI instance- Type
- CLI
-
setDescription(desc) → {CLI}
-
Parameters:
Name Type Description descstring Returns:
- Type
- CLI
-
setHidden(hidden) → {CLI}
-
Sets whether or not the current instance of CLI must be hidden. Hidden CLI are not listed when displaying usages / help messages. In other words, hidden commands are for power user.
Parameters:
Name Type Description hiddenboolean enables or disables the hidden aspect of the CI Returns:
the current CLI instance- Type
- CLI
-
setName(name) → {CLI}
-
Sets the name of the CLI.
Parameters:
Name Type Description namestring the name Returns:
the current CLI instance- Type
- CLI
-
setOptions(options) → {CLI}
-
Sets the list of arguments.
Parameters:
Name Type Description optionsArray.<Object> the list of options, must not be nullReturns:
the current CLI instance- Type
- CLI
-
setSummary(summary) → {CLI}
-
Sets the summary of the CLI.
Parameters:
Name Type Description summarystring the summary Returns:
the current CLI instance- Type
- CLI