Index: trunk/phase3/maintenance/renamewiki.php |
— | — | @@ -28,7 +28,8 @@ |
29 | 29 | public function __construct() { |
30 | 30 | parent::__construct(); |
31 | 31 | $this->mDescription = "Rename external storage dbs and leave a new one"; |
32 | | - $this->addArgs( array( 'olddb', 'newdb' ) ); |
| 32 | + $this->addArg( 'olddb' 'Old DB name' ); |
| 33 | + $this->addArg( 'newdb' 'New DB name' ); |
33 | 34 | } |
34 | 35 | |
35 | 36 | protected function getDbType() { |
Index: trunk/phase3/maintenance/mctest.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | $this->mDescription = "Makes several 'set', 'incr' and 'get' requests on every" |
31 | 31 | . " memcached server and shows a report"; |
32 | 32 | $this->addOption( 'i', 'Number of iterations', false, true ); |
33 | | - $this->addArgs( array( 'server' ) ); |
| 33 | + $this->addArg( 'server', 'Memcached server to test' ); |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function execute() { |
Index: trunk/phase3/maintenance/undelete.php |
— | — | @@ -14,7 +14,7 @@ |
15 | 15 | $this->mDescription = "Undelete a page"; |
16 | 16 | $this->addOption( 'u', 'The user to perform the undeletion', false, true ); |
17 | 17 | $this->addOption( 'r', 'The reason to undelete', false, true ); |
18 | | - $this->addArgs( array( 'pagename' ) ); |
| 18 | + $this->addArg( 'pagename', 'Page to undelete' ); |
19 | 19 | } |
20 | 20 | |
21 | 21 | public function execute() { |
Index: trunk/phase3/maintenance/rebuildFileCache.php |
— | — | @@ -26,8 +26,8 @@ |
27 | 27 | public function __construct() { |
28 | 28 | parent::__construct(); |
29 | 29 | $this->mDescription = "Build file cache for content pages"; |
30 | | - //$this->addArgs( array( 'start' ) ); |
31 | | - $this->addOption( 'overwrite', 'Refresh page cache', false ); |
| 30 | + $this->addArg( 'start', 'Page_id to start from', true ); |
| 31 | + $this->addArg( 'overwrite', 'Refresh page cache', false ); |
32 | 32 | $this->setBatchSize( 100 ); |
33 | 33 | } |
34 | 34 | |
Index: trunk/phase3/maintenance/refreshLinks.php |
— | — | @@ -30,7 +30,7 @@ |
31 | 31 | $this->addOption( 'old-redirects-only', 'Only fix redirects with no redirect table entry' ); |
32 | 32 | $this->addOption( 'm', 'Maximum replication lag', false, true ); |
33 | 33 | $this->addOption( 'e', 'Last page id to refresh', false, true ); |
34 | | - $this->addArgs( array( 'start' => true ) ); |
| 34 | + $this->addArg( 'start', 'Page_id to start from, default 1' ); |
35 | 35 | $this->setBatchSize( 100 ); |
36 | 36 | } |
37 | 37 | |
Index: trunk/phase3/maintenance/moveBatch.php |
— | — | @@ -42,7 +42,7 @@ |
43 | 43 | $this->addOption( 'u', "User to perform move", false, true ); |
44 | 44 | $this->addOption( 'r', "Reason to move page", false, true ); |
45 | 45 | $this->addOption( 'i', "Interval to sleep between moves" ); |
46 | | - $this->addArgs( array( 'listfile' ) ); |
| 46 | + $this->addArg( 'listfile', 'List of pages to move, newline delimited', false ); |
47 | 47 | } |
48 | 48 | |
49 | 49 | public function execute() { |
Index: trunk/phase3/maintenance/edit.php |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 | $this->addOption( 'b', 'Bot edit' ); |
34 | 34 | $this->addOption( 'a', 'Enable autosummary' ); |
35 | 35 | $this->addOption( 'no-rc', 'Do not show the change in recent changes' ); |
36 | | - $this->addArgs( array( 'title' ) ); |
| 36 | + $this->addArg( 'title', 'Title of article to edit' ); |
37 | 37 | } |
38 | 38 | |
39 | 39 | public function execute() { |
Index: trunk/phase3/maintenance/nukePage.php |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | parent::__construct(); |
31 | 31 | $this->mDescription = "Remove a page record from the database"; |
32 | 32 | $this->addOption( 'delete', "Actually delete the page" ); |
33 | | - $this->addArgs( array( 'title' ) ); |
| 33 | + $this->addArg( 'title', 'Title to delete' ); |
34 | 34 | } |
35 | 35 | |
36 | 36 | public function execute() { |
Index: trunk/phase3/maintenance/deleteBatch.php |
— | — | @@ -37,7 +37,7 @@ |
38 | 38 | $this->addOption( 'u', "User to perform deletion", false, true ); |
39 | 39 | $this->addOption( 'r', "Reason to delete page", false, true ); |
40 | 40 | $this->addOption( 'i', "Interval to sleep between deletions" ); |
41 | | - $this->addArgs( array( 'listfile' ) ); |
| 41 | + $this->addArg( 'listfile', 'File with titles to delete, separated by newlines', false ); |
42 | 42 | } |
43 | 43 | |
44 | 44 | public function execute() { |
Index: trunk/phase3/maintenance/addwiki.php |
— | — | @@ -29,7 +29,9 @@ |
30 | 30 | public function __construct() { |
31 | 31 | parent::__construct(); |
32 | 32 | $this->mDescription = "Add a new wiki to the family. Wikimedia specific!"; |
33 | | - $this->addArgs( 'language', 'site', 'dbname' ); |
| 33 | + $this->addArg( 'language', 'Language code of new site' ); |
| 34 | + $this->addArg( 'site', 'Type of site' ); |
| 35 | + $this->addArg( 'dbname', 'Name of database to create' ); |
34 | 36 | } |
35 | 37 | |
36 | 38 | protected function getDbType() { |
Index: trunk/phase3/maintenance/patchSql.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | public function __construct() { |
29 | 29 | parent::__construct(); |
30 | 30 | $this->mDescription = "Run an SQL file into the DB, replacing prefix and charset vars"; |
31 | | - $this->addArgs( array( 'patch-name' ) ); |
| 31 | + $this->addArg( 'patch-name', 'Name of the patch file, either full path or in maintenance/archives' ); |
32 | 32 | } |
33 | 33 | |
34 | 34 | protected function getDbType() { |
Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -137,10 +137,17 @@ |
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
141 | | - * Add some args that are needed. Used in formatting help |
| 141 | + * Add some args that are needed |
| 142 | + * @param $arg String Name of the arg, like 'start' |
| 143 | + * @param $description String Short description of the arg |
| 144 | + * @param $required Boolean Is this required? |
142 | 145 | */ |
143 | | - protected function addArgs( $args ) { |
144 | | - $this->mArgList = array_merge( $this->mArgList, $args ); |
| 146 | + protected function addArg( $arg, $description, $required = true ) { |
| 147 | + $this->mArgList[] = array( |
| 148 | + 'name' => $arg, |
| 149 | + 'desc' => $description, |
| 150 | + 'require' => $required |
| 151 | + ); |
145 | 152 | } |
146 | 153 | |
147 | 154 | /** |
— | — | @@ -462,17 +469,23 @@ |
463 | 470 | * Run some validation checks on the params, etc |
464 | 471 | */ |
465 | 472 | private function validateParamsAndArgs() { |
466 | | - # Check to make sure we've got all the required ones |
| 473 | + $die = false; |
| 474 | + # Check to make sure we've got all the required options |
467 | 475 | foreach( $this->mParams as $opt => $info ) { |
468 | 476 | if( $info['require'] && !$this->hasOption( $opt ) ) { |
469 | | - $this->error( "Param $opt required.", true ); |
| 477 | + $this->error( "Param $opt required!" ); |
| 478 | + $die = true; |
470 | 479 | } |
471 | 480 | } |
472 | | - |
473 | | - # Also make sure we've got enough arguments |
474 | | - if ( count( $this->mArgs ) < count( $this->mArgList ) ) { |
475 | | - $this->error( "Not enough arguments passed", true ); |
| 481 | + # Check arg list too |
| 482 | + foreach( $this->mArgList as $k => $info ) { |
| 483 | + if( $info['require'] && !$this->hasArg($k) ) { |
| 484 | + $this->error( "Argument <" . $info['name'] . "> required!" ); |
| 485 | + $die = true; |
| 486 | + } |
476 | 487 | } |
| 488 | + |
| 489 | + if( $die ) $this->maybeHelp( true ); |
477 | 490 | } |
478 | 491 | |
479 | 492 | /** |
— | — | @@ -505,12 +518,20 @@ |
506 | 519 | $this->output( " [--" . implode( array_keys( $this->mParams ), "|--" ) . "]" ); |
507 | 520 | } |
508 | 521 | if( $this->mArgList ) { |
509 | | - $this->output( " <" . implode( $this->mArgList, "> <" ) . ">" ); |
| 522 | + $this->output( " <" ); |
| 523 | + foreach( $this->mArgList as $k => $arg ) { |
| 524 | + $this->output( $arg['name'] . ">" ); |
| 525 | + if( $k < count( $this->mArgList ) - 1 ) |
| 526 | + $this->output( " <" ); |
| 527 | + } |
510 | 528 | } |
511 | 529 | $this->output( "\n" ); |
512 | 530 | foreach( $this->mParams as $par => $info ) { |
513 | 531 | $this->output( "\t$par : " . $info['desc'] . "\n" ); |
514 | 532 | } |
| 533 | + foreach( $this->mArgList as $info ) { |
| 534 | + $this->output( "\t<" . $info['name'] . "> : " . $info['desc'] . "\n" ); |
| 535 | + } |
515 | 536 | die( 1 ); |
516 | 537 | } |
517 | 538 | } |
Index: trunk/phase3/maintenance/createAndPromote.php |
— | — | @@ -30,7 +30,8 @@ |
31 | 31 | parent::__construct(); |
32 | 32 | $this->mDescription = "Create a new user account with administrator rights"; |
33 | 33 | $this->addOption( "bureaucrat", "Grant the account bureaucrat rights" ); |
34 | | - $this->addArgs( array( "username", "password" ) ); |
| 34 | + $this->addArg( "username", "Username of new user" ); |
| 35 | + $this->addArg( "password", "Password to set" ); |
35 | 36 | } |
36 | 37 | |
37 | 38 | public function execute() { |
Index: trunk/phase3/maintenance/fixTimestamps.php |
— | — | @@ -30,7 +30,9 @@ |
31 | 31 | public function __construct() { |
32 | 32 | parent::__construct(); |
33 | 33 | $this->mDescription = ""; |
34 | | - $this->addArgs( array( 'offset', 'start', 'end' ) ); |
| 34 | + $this->addArg( 'offset', '' ); |
| 35 | + $this->addArg( 'start', 'Starting timestamp' ); |
| 36 | + $this->addArg( 'end', 'Ending timestamp' ); |
35 | 37 | } |
36 | 38 | |
37 | 39 | public function execute() { |
Index: trunk/phase3/maintenance/reassignEdits.php |
— | — | @@ -31,7 +31,8 @@ |
32 | 32 | $this->addOption( "force", "Reassign even if the target user doesn't exist" ); |
33 | 33 | $this->addOption( "norc", "Don't update the recent changes table" ); |
34 | 34 | $this->addOption( "report", "Print out details of what would be changed, but don't update it" ); |
35 | | - $this->addArgs( array( 'from', 'to' ) ); |
| 35 | + $this->addArg( 'from', 'Old user to take edits from' ); |
| 36 | + $this->addArg( 'to', 'New user to give edits to' ); |
36 | 37 | } |
37 | 38 | |
38 | 39 | public function execute() { |
Index: trunk/phase3/maintenance/cleanupSpam.php |
— | — | @@ -27,7 +27,7 @@ |
28 | 28 | parent::__construct(); |
29 | 29 | $this->mDescription = "Cleanup all spam from a given hostname"; |
30 | 30 | $this->addOption( 'all', 'Check all wikis in $wgLocalDatabases' ); |
31 | | - $this->addArgs( array( 'hostname' ) ); |
| 31 | + $this->addArg( 'hostname', 'Hostname that was spamming' ); |
32 | 32 | } |
33 | 33 | |
34 | 34 | public function execute() { |
Index: trunk/phase3/maintenance/waitForSlave.php |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | |
25 | 25 | class WaitForSlave extends Maintenance { |
26 | 26 | public function __construct() { |
27 | | - $this->addArgs( array( 'maxlag' ) ); |
| 27 | + $this->addArg( 'maxlag', 'How long to wait for the slaves, default 10 seconds', false ); |
28 | 28 | } |
29 | 29 | public function execute() { |
30 | 30 | wfWaitForSlaves( $this->getArg( 0, 10 ) ); |