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 Default.php Default.php Default.php Element.php ex1.php ex2.php ex3.php ex4.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 119] Boolean that determine if the command line parser should add the help (-h, --help) option automatically.
[ Top ] $add_version_option = true[line 130] 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 183] An array of Console_CommandLine_Argument objects.
[ Top ] $commands = array()[line 190] An array of Console_CommandLine_Command objects (sub commands).
[ Top ] $description = ''[line 100] A description text that will be displayed in the help message.
[ Top ] $errors = array(
|
Type: | array |
[line 169]
Boolean that tells the parser to set relevant options default values, according to the option action.Type: | bool |
[line 160]
Boolean that tells the parser to be POSIX compliant, POSIX demands the following behavior: the first non-option stops option processing.Type: | bool |
[line 152]
The command line message provider instance.[line 93]
The name of the program, if not given it defaults to argv[0].Type: | string |
[line 176]
An array of Console_CommandLine_Option objects.Type: | array |
[line 145]
The command line parser outputter instance.[line 199]
Parent, only relevant in Command objects but left here for interface convenience.Type: | Console_CommandLine |
[line 138]
The command line parser renderer instance.Type: | object that |
[line 111]
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:
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 |
|
int | $exitCode | — | The exit code number |
|
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 |