Class: CLI

vertx-js/cli~ CLI

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

Source:

Methods

addArgument(arg) → {CLI}

Adds an argument.
Parameters:
Name Type Description
arg Object the argument, must not be null
Source:
Returns:
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
args Array.<Object> the arguments, must not be null
Source:
Returns:
the current CLI instance
Type
CLI

addOption(option) → {CLI}

Adds an option.
Parameters:
Name Type Description
option Object the option, must not be null.
Source:
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
options Array.<Object> the options, must not be null
Source:
Returns:
the current CLI instance
Type
CLI

getArgument(index) → {Object}

Gets an Argument based on its index.
Parameters:
Name Type Description
index number the index, must be positive or zero.
Source:
Returns:
the Argument, null if not found.
Type
Object

getArguments() → {Array.<Object>}

Gets the list of defined arguments.
Source:
Returns:
the list of argument, empty if none.
Type
Array.<Object>

getDescription() → {string}

Source:
Returns:
the CLI description.
Type
string

getName() → {string}

Source:
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
name string the name, must not be null
Source:
Returns:
the Option, null if not found
Type
Object

getOptions() → {Array.<Object>}

Gets the list of options.
Source:
Returns:
the list of options, empty if none.
Type
Array.<Object>

getSummary() → {string}

Source:
Returns:
the CLI summary.
Type
string

isHidden() → {boolean}

Checks whether or not the current CLI instance is hidden.
Source:
Returns:
true if 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
arguments Array.<string> the arguments
validate boolean enable / disable parsing validation
Source:
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
index number the argument index
Source:
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
name string the option name
Source:
Returns:
the current CLI instance
Type
CLI

setArguments(args) → {CLI}

Sets the list of arguments.
Parameters:
Name Type Description
args Array.<Object> the list of arguments, must not be null
Source:
Returns:
the current CLI instance
Type
CLI

setDescription(desc) → {CLI}

Parameters:
Name Type Description
desc string
Source:
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
hidden boolean enables or disables the hidden aspect of the CI
Source:
Returns:
the current CLI instance
Type
CLI

setName(name) → {CLI}

Sets the name of the CLI.
Parameters:
Name Type Description
name string the name
Source:
Returns:
the current CLI instance
Type
CLI

setOptions(options) → {CLI}

Sets the list of arguments.
Parameters:
Name Type Description
options Array.<Object> the list of options, must not be null
Source:
Returns:
the current CLI instance
Type
CLI

setSummary(summary) → {CLI}

Sets the summary of the CLI.
Parameters:
Name Type Description
summary string the summary
Source:
Returns:
the current CLI instance
Type
CLI