Class Argument
An input argument.
Args arguments are passed after the command name and its options. In the example below, "localhost" is the argument to the "server -d" command.
$ console server -d localhost
Arguments can be either optional or required. By default, all arguments are
optional, but you can explicitly make an argument optional or required by
passing one of the flags Webmozart\Console\Api\Args\Format\Argument::OPTIONAL
and Webmozart\Console\Api\Args\Format\Argument::REQUIRED
to the
constructor:
$argument = new Argument('server', Argument::REQUIRED);
Arguments can also be multi-valued. Multi-valued arguments can be passed any number of times:
$ console server -d localhost google.com
To create a multi-valued argument, pass the flag Webmozart\Console\Api\Args\Format\Argument::MULTI_VALUED
to the
constructor:
$argument = new Argument('server', Argument::MULTI_VALUED);
You can combine the Webmozart\Console\Api\Args\Format\Argument::MULTI_VALUED
flag with either Webmozart\Console\Api\Args\Format\Argument::OPTIONAL
or Webmozart\Console\Api\Args\Format\Argument::REQUIRED
using the bitwise operator "|":
$argument = new Argument('server', Argument::REQUIRED | Argument::MULTI_VALUED);
Author: Bernhard Schussek bschussek@gmail.com
Since: 1.0
Located at Api/Args/Format/Argument.php
public
|
#
__construct( string $name, integer $flags = 0, string $description = null, mixed $defaultValue = null )
Creates a new argument. |
public
string
|
|
public
boolean
|
|
public
boolean
|
|
public
boolean
|
|
public
|
|
public
mixed
|
|
public
mixed
|
|
public
string
|
integer |
REQUIRED
Flag: The argument is required. |
#
1
|
integer |
OPTIONAL
Flag: The argument is optional. |
#
2
|
integer |
MULTI_VALUED
Flag: The argument can be repeated multiple times. |
#
4
|
integer |
STRING
Flag: The value is parsed as string. |
#
16
|
integer |
BOOLEAN
Flag: The value is parsed as boolean. |
#
32
|
integer |
INTEGER
Flag: The value is parsed as integer. |
#
64
|
integer |
FLOAT
Flag: The value is parsed as float. |
#
128
|
integer |
NULLABLE
Flag: The value "null" should be parsed as |
#
256
|