Console_CommandLine |
![]() |
[ class tree: Console_CommandLine ] [ index: Console_CommandLine ] [ all elements ] |
![]() |
Packages: Console_CommandLine Classes:
Console_CommandLine
Files:Console_CommandLine_Action Console_CommandLine_Action_Callback Console_CommandLine_Action_Counter Console_CommandLine_Action_Help Console_CommandLine_Action_List Console_CommandLine_Action_Password Console_CommandLine_Action_StoreArray Console_CommandLine_Action_StoreFalse Console_CommandLine_Action_StoreFloat Console_CommandLine_Action_StoreInt Console_CommandLine_Action_StoreString Console_CommandLine_Action_StoreTrue Console_CommandLine_Action_Version Console_CommandLine_Argument Console_CommandLine_Command Console_CommandLine_Element Console_CommandLine_Exception Console_CommandLine_MessageProvider_Default Console_CommandLine_Option Console_CommandLine_Outputter_Default Console_CommandLine_Renderer_Default Console_CommandLine_Result Console_CommandLine_XmlParser
Action.php
Argument.php Callback.php Command.php CommandLine.php Counter.php CustomMessageProvider.php Default.php Default.php Default.php Element.php ex1.php ex2.php ex3.php ex4.php ex5.php Exception.php Help.php List.php MessageProvider.php Option.php Outputter.php Password.php Renderer.php Result.php StoreArray.php StoreFalse.php StoreFloat.php StoreInt.php StoreString.php StoreTrue.php Version.php XmlParser.php |
[ Top ] $add_help_option = true[line 120] Boolean that determine if the command line parser should add the help (-h, --help) option automatically.
[ Top ] $add_version_option = true[line 131] Boolean that determine if the command line parser should add the version (-v, --version) option automatically.Note that the version option is also generated only if the version property is not empty, it's up to you to provide a version string of course.
[ Top ] $args = array()[line 191] An array of Console_CommandLine_Argument objects.
[ Top ] $commands = array()[line 198] An array of Console_CommandLine_Command objects (sub commands).
[ Top ] $description = ''[line 101] A description text that will be displayed in the help message.
[ Top ] $errors = array(
|
Type: | array |
[line 177]
Boolean that tells the parser to set relevant options default values, according to the option action.Type: | bool |
[line 168]
Boolean that tells the parser to be POSIX compliant, POSIX demands the following behavior: the first non-option stops option processing.Type: | bool |
[line 264]
Custom errors messages for this commandThis array is of the form:
If specified, these messages override the messages provided by the default message provider. For example:
Type: | array |
[line 160]
The command line message provider instance.[line 94]
The name of the program, if not given it defaults to argv[0].Type: | string |
[line 184]
An array of Console_CommandLine_Option objects.Type: | array |
[line 153]
The command line parser outputter instance.[line 207]
Parent, only relevant in Command objects but left here for interface convenience.Type: | Console_CommandLine |
[line 146]
The command line parser renderer instance.Type: | object that |
[line 138]
Boolean that determine if providing a subcommand is mandatory.Type: | bool |
[line 112]
A string that represents the version of the program, if this property is not empty and property add_version_option is not set to false, the command line parser will add a --version option, that will display the property content.Type: | string |
|
Example:
Overridden in child classes as:
array | $params | — | An optional array of parameters |
|
mixed | $instance | — | The custom instance |
|
Adds an argument with the name $name and set its attributes with the array $params, then return the Console_CommandLine_Argument instance created. The method accepts another form: you can directly pass a Console_CommandLine_Argument object as the sole argument, this allows you to contruct the argument separately, in order to reuse it in different command line parsers or commands for example.
Example:
In a terminal, the help will be displayed like this:
mixed | $name | — | A string containing the argument name or an instance of Console_CommandLine_Argument |
array | $params | — | An array containing the argument attributes |
|
|
Adds a command with the given $name to the parser and returns the Console_CommandLine_Command instance, you can then populate the command with options, configure it, etc... like you would do for the main parser because the class Console_CommandLine_Command inherits from Console_CommandLine.
An example:
Then in a terminal:
mixed | $name | — | A string containing the command name or an instance of Console_CommandLine_Command |
array | $params | — | An array containing the command attributes |
|
Adds an option with the name $name and set its attributes with the array $params, then return the Console_CommandLine_Option instance created. The method accepts another form: you can directly pass a Console_CommandLine_Option object as the sole argument, this allows you to contruct the option separately, in order to reuse it in different command line parsers or commands for example.
Example:
In a terminal, the help will be displayed like this:
Various methods to specify an option, these 3 commands are equivalent:
mixed | $name | — | A string containing the option name or an instance of Console_CommandLine_Option |
array | $params | — | An array containing the option attributes |
|
string | $error | — | The error message |
int | $exitCode | — | The exit code number (default: 1). If set to false, the exit() function will not be called |
|
int | $exitCode | — | The exit code number (default: 0). If set to false, the exit() function will not be called |
|
int | $exitCode | — | The exit code number (default: 0). If set to false, the exit() function will not be called |
|
string | $str | — | The option identifier |
|
Example:
string | $file | — | Path to the xml file |
|
Example:
string | $string | — | The xml data |
|
|
integer | $userArgc | — | Number of arguments (optional) |
array | $userArgv | — | Array containing arguments (optional) |
|
string | $token | — | The command line token to parse |
object | $result | — | The Console_CommandLine_Result instance |
array | &$args | — | The argv array |
int | $argc | — | Number of lasting args |
|
string | $name | — | The name of the custom action |
string | $class | — | The class name of the custom action |
|
string | $msgId | — | Identifier of the message |
int | $level | — | The php error level |
array | $params | — | An array of search=>replaces entries |