An object to represent a single option used in the command line. ConsoleOptionParser creates these when you use addOption()
bool
Is the option a boolean option. Boolean options do not consume a parameter.
array<string>
An array of choices for the option.
string|bool|null
Default value for the option
string
Help text for the option.
bool
Can the option accept multiple value definition.
string
Name of the option
string
Short (1 character) alias for the option.
string|null
The prompt string
bool
Is the option required.
Make a new Input Option
Check if this option accepts multiple values.
Get the list of choices this option has.
Get the default value for this option
Generate the help for this this option.
Check if this option is a boolean option
Check if this option is required
Get the value of the name attribute.
Get the prompt string
Get the value of the short attribute.
Get the usage value for this option
Check that a value is a valid choice for this option.
Append the option's XML into the parent.
__construct(string $name, string $short = '', string $help = '', bool $isBoolean = false, string|bool|null $default = null, array<string> $choices = [], bool $multiple = false, bool $required = false, string|null $prompt = null)
Make a new Input Option
string
$name The long name of the option, or an array with all the properties.
string
$short optional The short alias for this option
string
$help optional The help text for this option
bool
$isBoolean optional Whether this option is a boolean option. Boolean options don't consume extra tokens
string|bool|null
$default optional The default value for this option.
array<string>
$choices optional Valid choices for this option.
bool
$multiple optional Whether this option can accept multiple value definition.
bool
$required optional Whether this option is required or not.
string|null
$prompt optional The prompt string.
Cake\Console\Exception\ConsoleException
acceptsMultiple(): bool
Check if this option accepts multiple values.
bool
choices(): array
Get the list of choices this option has.
array
defaultValue(): string|bool|null
Get the default value for this option
string|bool|null
help(int $width = 0): string
Generate the help for this this option.
int
$width optional The width to make the name of the option.
string
isBoolean(): bool
Check if this option is a boolean option
bool
isRequired(): bool
Check if this option is required
bool
name(): string
Get the value of the name attribute.
string
prompt(): string
Get the prompt string
string
short(): string
Get the value of the short attribute.
string
usage(): string
Get the usage value for this option
string
validChoice(string|bool $value): true
Check that a value is a valid choice for this option.
string|bool
$value The choice to validate.
true
Cake\Console\Exception\ConsoleException
xml(SimpleXMLElement $parent): SimpleXMLElement
Append the option's XML into the parent.
SimpleXMLElement
$parent The parent element.
SimpleXMLElement
Is the option a boolean option. Boolean options do not consume a parameter.
bool
An array of choices for the option.
array<string>
Default value for the option
string|bool|null
Help text for the option.
string
Can the option accept multiple value definition.
bool
Name of the option
string
Short (1 character) alias for the option.
string
The prompt string
string|null
Is the option required.
bool
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Console.ConsoleInputOption.html