\Cake\ConsoleConsoleInputOption

An object to represent a single option used in the command line.

ConsoleOptionParser creates these when you use addOption()

Summary

Methods
Properties
Constants
__construct()
name()
short()
help()
usage()
defaultValue()
isBoolean()
acceptsMultiple()
validChoice()
xml()
No public properties found
No constants found
No protected methods found
$_name
$_short
$_help
$_boolean
$_default
$_multiple
$_choices
N/A
No private methods found
No private properties found
N/A

Properties

$_name

$_name : string

Name of the option

Type

string

$_short

$_short : string

Short (1 character) alias for the option.

Type

string

$_help

$_help : string

Help text for the option.

Type

string

$_boolean

$_boolean : boolean

Is the option a boolean option. Boolean options do not consume a parameter.

Type

boolean

$_default

$_default : mixed

Default value for the option

Type

mixed

$_multiple

$_multiple : boolean

Can the option accept multiple value definition.

Type

boolean

$_choices

$_choices : array

An array of choices for the option.

Type

array

Methods

__construct()

__construct(string|array  $name, string  $short = '', string  $help = '', boolean  $boolean = false, string  $default = '', array  $choices = array(), boolean  $multiple = false) 

Make a new Input Option

Parameters

string|array $name

The long name of the option, or an array with all the properties.

string $short

The short alias for this option

string $help

The help text for this option

boolean $boolean

Whether this option is a boolean option. Boolean options don't consume extra tokens

string $default

The default value for this option.

array $choices

Valid choices for this option.

boolean $multiple

Whether this option can accept multiple value definition.

Throws

\Cake\Console\Exception\ConsoleException

name()

name() : string

Get the value of the name attribute.

Returns

string —

Value of this->_name.

short()

short() : string

Get the value of the short attribute.

Returns

string —

Value of this->_short.

help()

help(integer  $width) : string

Generate the help for this this option.

Parameters

integer $width

The width to make the name of the option.

Returns

string

usage()

usage() : string

Get the usage value for this option

Returns

string

defaultValue()

defaultValue() : mixed

Get the default value for this option

Returns

mixed

isBoolean()

isBoolean() : boolean

Check if this option is a boolean option

Returns

boolean

acceptsMultiple()

acceptsMultiple() : boolean

Check if this option accepts multiple values.

Returns

boolean

validChoice()

validChoice(string  $value) : boolean

Check that a value is a valid choice for this option.

Parameters

string $value

The choice to validate.

Throws

\Cake\Console\Exception\ConsoleException

Returns

boolean

xml()

xml(\SimpleXMLElement  $parent) : \SimpleXMLElement

Append the option's xml into the parent.

Parameters

\SimpleXMLElement $parent

The parent element.

Returns

\SimpleXMLElement —

The parent with this option appended.