|
MediaWiki master
|
Command line parameter handling for maintenance scripts. More...
Public Member Functions | |
| addArg (string $arg, string $description, bool $required=true, bool $multi=false) | |
| Define a positional argument. | |
| addOption (string $name, string $description, bool $required=false, bool $withArg=false, $shortName=false, bool $multiOccurrence=false) | |
| Add a option to the script. | |
| assignGroup (string $groupName, array $paramNames) | |
| Assigns a list of options to the given group. | |
| clear () | |
| Clear all parameter values. | |
| deleteOption (string $name) | |
| Remove an option. | |
| getArg ( $argId, ?string $default=null) | |
| Get an argument. | |
| getArgName (int $argIndex) | |
| Get the name of an argument at the given index. | |
| getArgs ( $offset=0) | |
| Get arguments. | |
| getErrors () | |
| Get any errors encountered while processing parameters. | |
| & | getFieldReference (string $fieldName) |
| Returns a reference to a member field. | |
| getHelp () | |
| Get help text. | |
| getName () | |
| Get the script name, as shown in the help message. | |
| getOption (string $name, $default=null) | |
| Get the value of an option, or return the default. | |
| getOptionNames () | |
| Returns the names of defined options. | |
| getOptions () | |
| Returns any option values. | |
| getOptionsSequence () | |
| Returns option values as an ordered sequence. | |
| hasArg ( $argId) | |
| Was a value for the given argument provided? | |
| hasErrors () | |
| Whether any errors have been recorded so far. | |
| hasOption (string $name) | |
| Checks to see if a particular option was set. | |
| loadWithArgv (array $argv, int $skip=0) | |
| Load params and arguments from a given array of command-line arguments. | |
| mergeOptions (MaintenanceParameters $other) | |
| Merge options declarations from $other into this instance. | |
| setAllowUnregisteredOptions (bool $allow) | |
| Sets whether to allow unknown options to be passed to the script. | |
| setArg ( $argId, $value) | |
| Programmatically set the value of the given argument. | |
| setDescription (string $text) | |
| Set a short description of what the script does. | |
| setName (string $name) | |
| Set the script name, for use in the help message. | |
| setOption (string $name, $value) | |
| Programmatically set the value of the given option. | |
| setOptionsAndArgs (array $opts, array $args) | |
| Force option and argument values. | |
| setUsagePrefix (string $usagePrefix) | |
| supportsOption (string $name) | |
| Checks to see if a particular option in supported. | |
| validate () | |
| Run some validation checks on the params, etc. | |
Command line parameter handling for maintenance scripts.
Definition at line 17 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::addArg | ( | string | $arg, |
| string | $description, | ||
| bool | $required = true, | ||
| bool | $multi = false ) |
Define a positional argument.
getArg() can later be used to get the value given for the argument, by index or by name.
| string | $arg | Name of the arg, like 'start' |
| string | $description | Short description of the arg |
| bool | $required | Is this required? |
| bool | $multi | Does it allow multiple values? (Last arg only) |
Definition at line 172 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::addOption | ( | string | $name, |
| string | $description, | ||
| bool | $required = false, | ||
| bool | $withArg = false, | ||
| $shortName = false, | |||
| bool | $multiOccurrence = false ) |
Add a option to the script.
Will be displayed on –help with the associated description
| string | $name | The name of the param (help, version, etc) |
| string | $description | The description of the param to show on –help |
| bool | $required | Is the param required? |
| bool | $withArg | Is an argument required with this option? |
| string | bool | $shortName | Character to use as short name |
| bool | $multiOccurrence | Can this option be passed multiple times? |
Definition at line 117 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::assignGroup | ( | string | $groupName, |
| array | $paramNames ) |
Assigns a list of options to the given group.
The given options will be shown as part of the given group in the help message.
| string | $groupName | |
| array | $paramNames |
Definition at line 89 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::clear | ( | ) |
Clear all parameter values.
Note that all parameter definitions remain intact.
Definition at line 324 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::deleteOption | ( | string | $name | ) |
Remove an option.
Useful for removing options that won't be used in your script.
| string | $name | The option to remove. |
Definition at line 209 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getArg | ( | $argId, | |
| ?string | $default = null ) |
Get an argument.
| int | string | $argId | The index (from zero) of the argument, or the name declared for the argument by addArg(). |
| string | null | $default | The default if it doesn't exist |
Definition at line 260 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getArgName | ( | int | $argIndex | ) |
Get the name of an argument at the given index.
| int | $argIndex | The integer value (from zero) for the arg |
Definition at line 290 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getArgs | ( | $offset = 0 | ) |
Get arguments.
| int | string | $offset | The index (from zero) of the first argument, or the name declared for the argument by addArg(). |
Definition at line 275 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getErrors | ( | ) |
Get any errors encountered while processing parameters.
Definition at line 457 of file MaintenanceParameters.php.
| & MediaWiki\Maintenance\MaintenanceParameters::getFieldReference | ( | string | $fieldName | ) |
Returns a reference to a member field.
This is a backwards compatibility hack, it should be removed as soon as possible!
| string | $fieldName |
Definition at line 77 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getHelp | ( | ) |
Get help text.
Definition at line 543 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getName | ( | ) |
Get the script name, as shown in the help message.
Definition at line 478 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getOption | ( | string | $name, |
| $default = null ) |
Get the value of an option, or return the default.
If the option was defined to support multiple occurrences, this will return an array.
| string | $name | The name of the param |
| mixed | null | $default | Anything you want, default null |
Definition at line 154 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getOptionNames | ( | ) |
Returns the names of defined options.
Definition at line 662 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getOptions | ( | ) |
Returns any option values.
Definition at line 669 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::getOptionsSequence | ( | ) |
Returns option values as an ordered sequence.
Useful for option chaining (Ex. dumpBackup.php).
Definition at line 678 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::hasArg | ( | $argId | ) |
Was a value for the given argument provided?
| int | string | $argId | The index (from zero) of the argument, or the name declared for the argument by addArg(). |
Definition at line 243 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::hasErrors | ( | ) |
Whether any errors have been recorded so far.
Definition at line 464 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::hasOption | ( | string | $name | ) |
Checks to see if a particular option was set.
| string | $name | The name of the option |
Definition at line 139 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::loadWithArgv | ( | array | $argv, |
| int | $skip = 0 ) |
Load params and arguments from a given array of command-line arguments.
| array | $argv | The argument array. |
| int | $skip | Skip that many elements at the beginning of $argv. |
Definition at line 350 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::mergeOptions | ( | MaintenanceParameters | $other | ) |
Merge options declarations from $other into this instance.
Definition at line 334 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::setAllowUnregisteredOptions | ( | bool | $allow | ) |
Sets whether to allow unknown options to be passed to the script.
By default, unknown options cause an error.
| bool | $allow | Should we allow? |
Definition at line 226 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::setArg | ( | $argId, | |
| $value ) |
Programmatically set the value of the given argument.
Useful for setting up child scripts, see runChild().
| string | int | $argId | |
| string | $value |
Definition at line 312 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::setDescription | ( | string | $text | ) |
Set a short description of what the script does.
Definition at line 233 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::setName | ( | string | $name | ) |
Set the script name, for use in the help message.
Definition at line 471 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::setOption | ( | string | $name, |
| $value ) |
Programmatically set the value of the given option.
Useful for setting up child scripts, see runChild().
| string | $name | |
| mixed | null | $value |
Definition at line 301 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::setOptionsAndArgs | ( | array | $opts, |
| array | $args ) |
Force option and argument values.
| array | $opts | |
| array | $args |
Definition at line 490 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::setUsagePrefix | ( | string | $usagePrefix | ) |
Definition at line 682 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::supportsOption | ( | string | $name | ) |
Checks to see if a particular option in supported.
Normally this means it has been registered by the script via addOption.
| string | $name | The name of the option<string,string> |
Definition at line 102 of file MaintenanceParameters.php.
| MediaWiki\Maintenance\MaintenanceParameters::validate | ( | ) |
Run some validation checks on the params, etc.
Error details can be obtained via getErrors().
Definition at line 511 of file MaintenanceParameters.php.