$action = 'StoreString'
[line 66]
The option action, defaults to "StoreString".
- Var: Option action
- Access: public
$action_params = array()
[line 127]
An associative array of additional params to pass to the class corresponding to the action, this array will also be passed to the callback defined for an action of type Callback, Example:
// for a custom action
$parser->addOption('myoption', array(
'short_name' => '-m',
'long_name' => '--myoption',
'action' => 'MyCustomAction',
'action_params' => array('foo'=>true, 'bar'=>false)
));
// if the user type:
// $ <yourprogram> -m spam
// in your MyCustomAction class the execute() method will be called
// with the value 'spam' as first parameter and
// array('foo'=>true, 'bar'=>false) as second parameter
- Var: Additional parameters to pass to the action
- Access: public
$add_list_option = false
[line 144]
For options that uses the "choice" property only.
Adds a --list-<choice> option to the parser that displays the list of choices for the option.
- Var: Whether to add a list option or not
- Access: public
$argument_optional = false
[line 135]
For options that expect an argument, this property tells the parser if the option argument is optional and can be ommited.
- Var: Whether the option arg is optional or not
- Access: public
$callback =
[line 102]
The callback function (or method) to call for an action of type Callback, this can be any callable supported by the php function call_user_func.
Example:
$parser->addOption('myoption', array(
'short_name' => '-m',
'long_name' => '--myoption',
'action' => 'Callback',
'callback' => 'myCallbackFunction'
));
- Var: The option callback
- Access: public
$choices = array()
[line 82]
An array of possible values for the option. If this array is not empty and the value passed is not in the array an exception is raised.
This only make sense for actions that accept values of course.
- Var: Valid choices for the option
- Access: public
$default =
[line 73]
The default value of the option if not provided on the command line.
- Var: Default value of the option.
- Access: public
$long_name =
[line 59]
The option long name (ex: --verbose).
- Var: Long name of the option
- Access: public
$short_name =
[line 52]
The option short name (ex: -v).
- Var: Short name of the option
- Access: public
__construct (Constructor) [line 167]
void __construct(
[string
$name = null], [array
$params = array()])
Constructor.
Overrides
Console_CommandLine_Element::__construct() (Constructor.)
Parameters:
string
$name
—
The name of the option
array
$params
—
An optional array of parameters
dispatchAction [line 241]
Formats the value $value according to the action of the option and updates the passed Console_CommandLine_Result object.
- Throws: Console_CommandLine_Exception
- Access: public
Parameters:
mixed
$value
—
The value to format
expectsArgument [line 217]
Returns true if the option requires one or more argument and false otherwise.
- Return: Whether the option expects an argument or not
- Access: public
setDefaults [line 344]
Set the default value according to the configured action.
Note that for backward compatibility issues this method is only called when the 'force_options_defaults' is set to true, it will become the default behaviour in the next major release of Console_CommandLine.
toString [line 188]
string toString(
[string
$delim = ", "])
Returns the string representation of the option.
- Return: The string representation of the option
- Todo: use __toString() instead
- Access: public
Overrides
Console_CommandLine_Element::toString() (Returns the string representation of the element.)
Parameters:
string
$delim
—
Delimiter to use between short and long option
validate [line 280]
Validates the option instance.
- Todo: use exceptions instead
- Throws: Console_CommandLine_Exception
- Access: public
Overrides
Console_CommandLine_Element::validate() (Validates the element instance and set it's default values.)