ILIAS
Release_5_0_x_branch Revision 61816
|
Public Member Functions | |
getopt2 ($args, $short_options, $long_options=null, $skip_unknown=false) | |
Parses the command-line options. | |
getopt ($args, $short_options, $long_options=null, $skip_unknown=false) | |
This function expects $args to start with the script name (POSIX-style). | |
doGetopt ($version, $args, $short_options, $long_options=null, $skip_unknown=false) | |
The actual implementation of the argument parsing code. | |
_parseShortOption ($arg, $short_options, &$opts, &$args, $skip_unknown) | |
Parse short option. | |
_isShortOpt ($arg) | |
Checks if an argument is a short option. | |
_isLongOpt ($arg) | |
Checks if an argument is a long option. | |
_parseLongOption ($arg, $long_options, &$opts, &$args, $skip_unknown) | |
Parse long option. | |
readPHPArgv () | |
Safely read the $argv PHP array across different PHP configurations. |
Definition at line 35 of file Getopt.php.
Console_Getopt::_isLongOpt | ( | $arg | ) |
Checks if an argument is a long option.
string | $arg | Argument to check |
private
Definition at line 258 of file Getopt.php.
Referenced by _parseLongOption(), and _parseShortOption().
Console_Getopt::_isShortOpt | ( | $arg | ) |
Checks if an argument is a short option.
string | $arg | Argument to check |
private
Definition at line 244 of file Getopt.php.
Referenced by _parseLongOption(), and _parseShortOption().
Console_Getopt::_parseLongOption | ( | $arg, | |
$long_options, | |||
& | $opts, | ||
& | $args, | ||
$skip_unknown | |||
) |
Parse long option.
string | $arg | Argument |
string[] | $long_options Available long options | |
string[][] | &$opts | |
string[] | &$args |
private
Definition at line 275 of file Getopt.php.
References _isLongOpt(), _isShortOpt(), and PEAR\raiseError().
Referenced by doGetopt().
Console_Getopt::_parseShortOption | ( | $arg, | |
$short_options, | |||
& | $opts, | ||
& | $args, | ||
$skip_unknown | |||
) |
Parse short option.
string | $arg | Argument |
string[] | $short_options Available short options | |
string[][] | &$opts | |
string[] | &$args | |
boolean | $skip_unknown | suppresses Console_Getopt: unrecognized option |
private
Definition at line 188 of file Getopt.php.
References _isLongOpt(), _isShortOpt(), and PEAR\raiseError().
Referenced by doGetopt().
Console_Getopt::doGetopt | ( | $version, | |
$args, | |||
$short_options, | |||
$long_options = null , |
|||
$skip_unknown = false |
|||
) |
The actual implementation of the argument parsing code.
int | $version | Version to use |
array | $args | an array of command-line arguments |
string | $short_options | specifies the list of allowed short options |
array | $long_options | specifies the list of allowed long options |
boolean | $skip_unknown | suppresses Console_Getopt: unrecognized option |
Definition at line 106 of file Getopt.php.
References _parseLongOption(), _parseShortOption(), and PEAR\isError().
Referenced by getopt(), and getopt2().
Console_Getopt::getopt | ( | $args, | |
$short_options, | |||
$long_options = null , |
|||
$skip_unknown = false |
|||
) |
This function expects $args to start with the script name (POSIX-style).
Preserved for backwards compatibility.
array | $args | an array of command-line arguments |
string | $short_options | specifies the list of allowed short options |
array | $long_options | specifies the list of allowed long options |
Definition at line 90 of file Getopt.php.
References doGetopt().
Console_Getopt::getopt2 | ( | $args, | |
$short_options, | |||
$long_options = null , |
|||
$skip_unknown = false |
|||
) |
Parses the command-line options.
The first parameter to this function should be the list of command-line arguments without the leading reference to the running program.
The second parameter is a string of allowed short options. Each of the option letters can be followed by a colon ':' to specify that the option requires an argument, or a double colon '::' to specify that the option takes an optional argument.
The third argument is an optional array of allowed long options. The leading '–' should not be included in the option name. Options that require an argument should be followed by '=', and options that take an option argument should be followed by '=='.
The return value is an array of two elements: the list of parsed options and the list of non-option command-line arguments. Each entry in the list of parsed options is a pair of elements - the first one specifies the option, and the second one specifies the option argument, if there was one.
Long and short options can be mixed.
Most of the semantics of this function are based on GNU getopt_long().
array | $args | an array of command-line arguments |
string | $short_options | specifies the list of allowed short options |
array | $long_options | specifies the list of allowed long options |
boolean | $skip_unknown | suppresses Console_Getopt: unrecognized option |
Definition at line 73 of file Getopt.php.
References doGetopt().
Referenced by System\_parseArgs().
Console_Getopt::readPHPArgv | ( | ) |
Safely read the $argv PHP array across different PHP configurations.
Will take care on register_globals and register_argc_argv ini directives
public
Definition at line 350 of file Getopt.php.
References $GLOBALS, and PEAR\raiseError().