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

see

while argument are defined using @see \io\vertx\jphp\core\cli\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 @see \io\vertx\jphp\core\cli\CommandLine object containing the argument and option values.

package

Default

Methods

__construct

__construct() 

Adds an argument.

addArgument( $arg0) : $this

Arguments

$arg0

Argument | array

Response

$this

the current {@link CLI} instance

Adds a set of arguments. Unlike @see \io\vertx\jphp\core\cli\CLI::setArguments, this method does not remove the existing arguments.

addArguments( $arg0) : $this

The given list is appended to the existing list.

Arguments

$arg0

array

Response

$this

the current {@link CLI} instance

Adds an option.

addOption( $arg0) : $this

Arguments

$arg0

array | Option

Response

$this

the current {@link CLI} instance

Adds a set of options. Unlike @see \io\vertx\jphp\core\cli\CLI::setOptions}, this method does not remove the existing options.

addOptions( $arg0) : $this

The given list is appended to the existing list.

Arguments

$arg0

array

Response

$this

the current {@link CLI} instance

Creates an instance of @see \io\vertx\jphp\core\cli\CLI using the default implementation.

create( $arg0) : \io\vertx\jphp\core\cli\CLI
static

Arguments

$arg0

string

Response

\io\vertx\jphp\core\cli\CLI

the created instance of {@link CLI}

Gets an @see \io\vertx\jphp\core\cli\Argument based on its name (argument name).

getArgument( $arg0) : \io\vertx\jphp\core\cli\Argument

param $name [string] the name of the argument, must not be {@code null} getArgument($name)

Gets an @see \io\vertx\jphp\core\cli\Argument based on its index.

param $index [integer] the index, must be positive or zero. getArgument($index)

Arguments

$arg0

string | integer

Response

\io\vertx\jphp\core\cli\Argument

the {@link Argument}, {@code null} if not found.

Gets the list of defined arguments.

getArguments() : array

Response

array

the list of argument, empty if none.

getDescription

getDescription() : string

Response

string

the CLI description.

getName

getName() : string

Response

string

the CLI name.

Gets an @see \io\vertx\jphp\core\cli\Option based on its name (short name, long name or argument name).

getOption( $arg0) : \io\vertx\jphp\core\cli\Option

Arguments

$arg0

string

Response

\io\vertx\jphp\core\cli\Option

the {@link Option}, {@code null} if not found

Gets the list of options.

getOptions() : array

Response

array

the list of options, empty if none.

getSummary

getSummary() : string

Response

string

the CLI summary.

Checks whether or not the current @see \io\vertx\jphp\core\cli\CLI instance is hidden.

isHidden() : boolean

Response

boolean

{@code true} if the current {@link CLI} is hidden, {@link false} otherwise

Parses the user command line interface and create a new @see \io\vertx\jphp\core\cli\CommandLine containing extracting values.

parse( $arg0,  $arg1 = null) : \io\vertx\jphp\core\cli\CommandLine

param $arguments [array] the arguments parse($arguments)

Parses the user command line interface and create a new @see \io\vertx\jphp\core\cli\CommandLine containing extracting values.

param $arguments [array] the arguments param $validate [boolean] enable / disable parsing validation parse($arguments, $validate)

Arguments

$arg0

array

$arg1

boolean

Response

\io\vertx\jphp\core\cli\CommandLine

the creates command line

Removes an argument identified by its index. This method does nothing if the argument cannot be found.

removeArgument( $arg0) : $this

Arguments

$arg0

integer

Response

$this

the current {@link CLI} instance

Removes an option identified by its name. This method does nothing if the option cannot be found.

removeOption( $arg0) : $this

Arguments

$arg0

string

Response

$this

the current {@link CLI} instance

Sets the list of arguments.

setArguments( $arg0) : $this

Arguments

$arg0

array

Response

$this

the current {@link CLI} instance

setDescription

setDescription( $arg0) : $this

Arguments

$arg0

string

Response

$this

Sets whether or not the current instance of @see \io\vertx\jphp\core\cli\CLI must be hidden. Hidden CLI are not listed when displaying usages / help messages. In other words, hidden commands are for power user.

setHidden( $arg0) : $this

Arguments

$arg0

boolean

Response

$this

the current {@link CLI} instance

Sets the name of the CLI.

setName( $arg0) : $this

Arguments

$arg0

string

Response

$this

the current {@link CLI} instance

Sets the list of arguments.

setOptions( $arg0) : $this

Arguments

$arg0

array

Response

$this

the current {@link CLI} instance

Sets the summary of the CLI.

setSummary( $arg0) : $this

Arguments

$arg0

string

Response

$this

the current {@link CLI} instance