MediaWiki master
CommandLineInc.php
Go to the documentation of this file.
1<?php
25
26// NO_AUTOLOAD -- unsafe file-scope code
27
28require_once __DIR__ . '/Maintenance.php';
29
31
32if ( !isset( $optionsWithArgs ) ) {
34}
35if ( !isset( $optionsWithoutArgs ) ) {
37}
38if ( !isset( $allowUnregisteredOptions ) ) {
40}
41
43 public function __construct() {
45
46 parent::__construct();
47
48 foreach ( $optionsWithArgs as $name ) {
49 $this->addOption( $name, '', false, true );
50 }
51 foreach ( $optionsWithoutArgs as $name ) {
52 $this->addOption( $name, '', false, false );
53 }
54
55 $this->setAllowUnregisteredOptions( $allowUnregisteredOptions );
56 }
57
62 protected function maybeHelp( $force = false ) {
63 if ( !$force ) {
64 return;
65 }
66 parent::maybeHelp( true );
67 }
68
69 public function execute() {
70 global $args, $options;
71
72 $args = $this->parameters->getArgs();
73 $options = $this->parameters->getOptions();
74 }
75}
76
77// @codeCoverageIgnoreStart
78$maintClass = CommandLineInc::class;
79require_once RUN_MAINTENANCE_IF_MAIN;
80// @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...