Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Public Member Functions | |
__construct ($rules, $argv=null, $getoptConfig=array()) | |
__get ($key) | |
__isset ($key) | |
__set ($key, $value) | |
__toString () | |
__unset ($key) | |
addArguments ($argv) | |
setArguments ($argv) | |
setOptions ($getoptConfig) | |
setOption ($configKey, $configValue) | |
addRules ($rules) | |
toString () | |
toArray () | |
toJson () | |
toXml () | |
getOptions () | |
getOption ($flag) | |
getRemainingArgs () | |
getUsageMessage () | |
setAliases ($aliasMap) | |
setHelp ($helpMap) | |
parse () | |
checkRequiredArguments () | |
Data Fields | |
const | MODE_ZEND = 'zend' |
const | MODE_GNU = 'gnu' |
const | PARAM_REQUIRED = '=' |
const | PARAM_OPTIONAL = '-' |
const | TYPE_STRING = 's' |
const | TYPE_WORD = 'w' |
const | TYPE_INTEGER = 'i' |
const | CONFIG_RULEMODE = 'ruleMode' |
const | CONFIG_DASHDASH = 'dashDash' |
const | CONFIG_IGNORECASE = 'ignoreCase' |
const | CONFIG_PARSEALL = 'parseAll' |
Protected Member Functions | |
_parseLongOption (&$argv) | |
_parseShortOptionCluster (&$argv) | |
_parseSingleOption ($flag, &$argv) | |
_checkParameterType ($flag, $param) | |
_addRulesModeGnu ($rules) | |
_addRulesModeZend ($rules) | |
Protected Attributes | |
$_getoptConfig | |
$_argv = array() | |
$_progname = '' | |
$_rules = array() | |
$_ruleMap = array() | |
$_options = array() | |
$_remainingArgs = array() | |
$_parsed = false | |
Definition at line 127 of file Getopt.php.
__construct | ( | $rules, | |
$argv = null , |
|||
$getoptConfig = array() |
|||
) |
The constructor takes one to three parameters.
The first parameter is $rules, which may be a string for gnu-style format, or a structured array for Zend-style format.
The second parameter is $argv, and it is optional. If not specified, $argv is inferred from the global argv.
The third parameter is an array of configuration parameters to control the behavior of this instance of Getopt; it is optional.
array | $rules | |
array | $argv | |
array | $getoptConfig |
Definition at line 242 of file Getopt.php.
__get | ( | $key | ) |
Return the state of the option seen on the command line of the current application invocation. This function returns true, or the parameter to the option, if any. If the option was not given, this function returns null.
The magic __get method works in the context of naming the option as a virtual member of this class.
string | $key |
Definition at line 280 of file Getopt.php.
__isset | ( | $key | ) |
Test whether a given option has been seen.
string | $key |
Definition at line 291 of file Getopt.php.
__set | ( | $key, | |
$value | |||
) |
Set the value for a given option.
string | $key | |
string | $value |
Definition at line 308 of file Getopt.php.
__toString | ( | ) |
Return the current set of options and parameters seen as a string.
Definition at line 322 of file Getopt.php.
__unset | ( | $key | ) |
|
protected |
Define legal options using the gnu-style format.
string | $rules |
Options may be single alphanumeric characters. Options may have a ':' which indicates a required string parameter. No long options or option aliases are supported in GNU style.
Definition at line 884 of file Getopt.php.
|
protected |
Define legal options using the Zend-style format.
array | $rules |
Zend_Console_Getopt_Exception |
Definition at line 919 of file Getopt.php.
|
protected |
Return true if the parameter is in a valid format for the option $flag. Throw an exception in most other cases.
string | $flag | |
string | $param |
Zend_Console_Getopt_Exception |
Definition at line 848 of file Getopt.php.
|
protected |
Parse command-line arguments for a single long option. A long option is preceded by a double '–' character. Long options may not be clustered.
mixed | &$argv |
Definition at line 764 of file Getopt.php.
|
protected |
Parse command-line arguments for short options. Short options are those preceded by a single '-' character. Short options may be clustered.
mixed | &$argv |
Definition at line 784 of file Getopt.php.
|
protected |
Parse command-line arguments for a single option.
string | $flag | |
mixed | $argv |
Zend_Console_Getopt_Exception |
Definition at line 800 of file Getopt.php.
addArguments | ( | $argv | ) |
Define additional command-line arguments. These are appended to those defined when the constructor was called.
array | $argv |
Zend_Console_Getopt_Exception | When not given an array as parameter |
Definition at line 350 of file Getopt.php.
addRules | ( | $rules | ) |
Define additional option rules. These are appended to the rules defined when the constructor was called.
array | $rules |
Call addRulesModeFoo() for ruleMode 'foo'. The developer should subclass Getopt and provide this method.
Definition at line 424 of file Getopt.php.
checkRequiredArguments | ( | ) |
Zend_Console_Getopt_Exception |
Definition at line 737 of file Getopt.php.
getOption | ( | $flag | ) |
Return the state of the option seen on the command line of the current application invocation.
This function returns true, or the parameter value to the option, if any. If the option was not given, this function returns null.
string | $flag |
Definition at line 558 of file Getopt.php.
getOptions | ( | ) |
Return a list of options that have been seen in the current argv.
Definition at line 542 of file Getopt.php.
getRemainingArgs | ( | ) |
Return the arguments from the command-line following all options found.
Definition at line 578 of file Getopt.php.
getUsageMessage | ( | ) |
Return a useful option reference, formatted for display in an error message.
Note that this usage information is provided in most Exceptions generated by this class.
Definition at line 593 of file Getopt.php.
parse | ( | ) |
Parse command-line arguments and find both long and short options.
Also find option parameters, and remaining arguments after all options have been parsed.
Definition at line 699 of file Getopt.php.
setAliases | ( | $aliasMap | ) |
Define aliases for options.
The parameter $aliasMap is an associative array mapping option name (short or long) to an alias.
array | $aliasMap |
Zend_Console_Getopt_Exception |
Definition at line 644 of file Getopt.php.
setArguments | ( | $argv | ) |
Define full set of command-line arguments. These replace any currently defined.
array | $argv |
Zend_Console_Getopt_Exception | When not given an array as parameter |
Definition at line 370 of file Getopt.php.
setHelp | ( | $helpMap | ) |
Define help messages for options.
The parameter $help_map is an associative array mapping option name (short or long) to the help string.
array | $helpMap |
Definition at line 677 of file Getopt.php.
setOption | ( | $configKey, | |
$configValue | |||
) |
Define one configuration option as a key/value pair. These are not program options, but properties to configure the behavior of Zend_Console_Getopt.
string | $configKey | |
string | $configValue |
Definition at line 409 of file Getopt.php.
setOptions | ( | $getoptConfig | ) |
Define multiple configuration options from an associative array. These are not program options, but properties to configure the behavior of Zend_Console_Getopt.
array | $getoptConfig |
Definition at line 390 of file Getopt.php.
toArray | ( | ) |
Return the current set of options and parameters seen as an array of canonical options and parameters.
Clusters have been expanded, and option aliases have been mapped to their primary option names.
Definition at line 474 of file Getopt.php.
toJson | ( | ) |
Return the current set of options and parameters seen in Json format.
Definition at line 492 of file Getopt.php.
toString | ( | ) |
Return the current set of options and parameters seen as a string.
Definition at line 455 of file Getopt.php.
toXml | ( | ) |
Return the current set of options and parameters seen in XML format.
Definition at line 519 of file Getopt.php.
|
protected |
Definition at line 180 of file Getopt.php.
|
protected |
Defaults for getopt configuration are: ruleMode is 'zend' format, dashDash (–) token is enabled, ignoreCase is not enabled, parseAll is enabled.
Definition at line 168 of file Getopt.php.
|
protected |
Definition at line 209 of file Getopt.php.
|
protected |
Definition at line 223 of file Getopt.php.
|
protected |
Definition at line 187 of file Getopt.php.
|
protected |
Definition at line 216 of file Getopt.php.
|
protected |
Definition at line 201 of file Getopt.php.
|
protected |
Definition at line 194 of file Getopt.php.
const CONFIG_DASHDASH = 'dashDash' |
Definition at line 157 of file Getopt.php.
const CONFIG_IGNORECASE = 'ignoreCase' |
Definition at line 158 of file Getopt.php.
const CONFIG_PARSEALL = 'parseAll' |
Definition at line 159 of file Getopt.php.
const CONFIG_RULEMODE = 'ruleMode' |
These are constants for optional behavior of this class. ruleMode is either 'zend' or 'gnu' or a user-defined mode. dashDash is true if '–' signifies the end of command-line options. ignoreCase is true if '–opt' and '–OPT' are implicitly synonyms. parseAll is true if all options on the command line should be parsed, regardless of whether an argument appears before them.
Definition at line 156 of file Getopt.php.
const MODE_GNU = 'gnu' |
Definition at line 136 of file Getopt.php.
const MODE_ZEND = 'zend' |
The options for a given application can be in multiple formats. modeGnu is for traditional 'ab:c:' style getopt format. modeZend is for a more structured format.
Definition at line 135 of file Getopt.php.
const PARAM_OPTIONAL = '-' |
Definition at line 143 of file Getopt.php.
const PARAM_REQUIRED = '=' |
Constant tokens for various symbols used in the mode_zend rule format.
Definition at line 142 of file Getopt.php.
const TYPE_INTEGER = 'i' |
Definition at line 146 of file Getopt.php.
const TYPE_STRING = 's' |
Definition at line 144 of file Getopt.php.
const TYPE_WORD = 'w' |
Definition at line 145 of file Getopt.php.