MediaWiki master
CommandLineInc.php
Go to the documentation of this file.
1<?php
11
12// NO_AUTOLOAD -- unsafe file-scope code
13
14require_once __DIR__ . '/Maintenance.php';
15
17
18if ( !isset( $optionsWithArgs ) ) {
20}
21if ( !isset( $optionsWithoutArgs ) ) {
23}
24if ( !isset( $allowUnregisteredOptions ) ) {
26}
27
29 public function __construct() {
31
32 parent::__construct();
33
34 foreach ( $optionsWithArgs as $name ) {
35 $this->addOption( $name, '', false, true );
36 }
37 foreach ( $optionsWithoutArgs as $name ) {
38 $this->addOption( $name, '', false, false );
39 }
40
41 $this->setAllowUnregisteredOptions( $allowUnregisteredOptions );
42 }
43
48 protected function maybeHelp( $force = false ) {
49 if ( !$force ) {
50 return;
51 }
52 parent::maybeHelp( true );
53 }
54
55 public function execute() {
56 global $args, $options;
57
58 $args = $this->parameters->getArgs();
59 $options = $this->parameters->getOptions();
60 }
61}
62
63// @codeCoverageIgnoreStart
64$maintClass = CommandLineInc::class;
65require_once RUN_MAINTENANCE_IF_MAIN;
66// @codeCoverageIgnoreEnd
global $optionsWithArgs
$maintClass
global $allowUnregisteredOptions
global $optionsWithoutArgs
execute()
Do the actual work.
maybeHelp( $force=false)
No help, it would just be misleading since it misses custom options.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
setAllowUnregisteredOptions( $allow)
Sets whether to allow unregistered options, which are options passed to a script that do not match an...