Console_CommandLine constructor takes an optional array of parameters explained in the table below. Note that if you are using an XML definition file, you can pass these parameters in it (see XML example for details).
Table 38-1. Available parameters
name | type | required | description |
---|---|---|---|
name | string | no, default to $argv[0] if not given | the name of your program |
description | string | no, but recommended for the help message | the description of your program: this should explain what your program is supposed to do |
version | mixed (string or numeric) | no, note that if not given, the --version option will not be available | the program version number |
add_help_option | boolean | no, default to TRUE | if set to FALSE the parser will not generate automatically the "help" option |
add_version_option | boolean | no, default to TRUE | if set to FALSE the parser will not generate automatically the "version" option |
force_posix | boolean | no, default to FALSE | if set to TRUE, the parser will force POSIX compliance (please see the gettext manual for more information) |
The examples below demonstrate how to instanciate Console_CommandLine and build a parser using PHP code.
Example 38-1. The simplest way
|
Example 38-2. Alternative method
|
The examples below demonstrate how to instanciate Console_CommandLine and build a parser using an XML definition file, this can be very useful if you have a big program or if you need to reuse your user interface settings for a web frontend for example.
Example 38-3. The XML file
|
Example 38-4. The PHP file
|
Note: Using and XML string you would have called fromXmlString()() instead of fromXmlFile()() of course.