MediaWiki master
CommandLineInc.php
Go to the documentation of this file.
1<?php
24// NO_AUTOLOAD -- unsafe file-scope code
25
26require_once __DIR__ . '/Maintenance.php';
27
29
30if ( !isset( $optionsWithArgs ) ) {
32}
33if ( !isset( $optionsWithoutArgs ) ) {
35}
36if ( !isset( $allowUnregisteredOptions ) ) {
38}
39
41 public function __construct() {
43
44 parent::__construct();
45
46 foreach ( $optionsWithArgs as $name ) {
47 $this->addOption( $name, '', false, true );
48 }
49 foreach ( $optionsWithoutArgs as $name ) {
50 $this->addOption( $name, '', false, false );
51 }
52
53 $this->setAllowUnregisteredOptions( $allowUnregisteredOptions );
54 }
55
60 protected function maybeHelp( $force = false ) {
61 if ( !$force ) {
62 return;
63 }
64 parent::maybeHelp( true );
65 }
66
67 public function execute() {
68 global $args, $options;
69
70 $args = $this->parameters->getArgs();
71 $options = $this->parameters->getOptions();
72 }
73}
74
75$maintClass = CommandLineInc::class;
76require_once RUN_MAINTENANCE_IF_MAIN;
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...
setAllowUnregisteredOptions( $allow)
Sets whether to allow unregistered options, which are options passed to a script that do not match an...
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.