Index: trunk/phase3/maintenance/Maintenance.php |
— | — | @@ -70,6 +70,9 @@ |
71 | 71 | // This is the desired params |
72 | 72 | protected $mParams = array(); |
73 | 73 | |
| 74 | + // Array of mapping short parameters to long ones |
| 75 | + protected $mShortParamsMap = array(); |
| 76 | + |
74 | 77 | // Array of desired args |
75 | 78 | protected $mArgList = array(); |
76 | 79 | |
— | — | @@ -157,9 +160,13 @@ |
158 | 161 | * @param $description String: the description of the param to show on --help |
159 | 162 | * @param $required Boolean: is the param required? |
160 | 163 | * @param $withArg Boolean: is an argument required with this option? |
| 164 | + * @param $shortName String: character to use as short name |
161 | 165 | */ |
162 | | - protected function addOption( $name, $description, $required = false, $withArg = false ) { |
163 | | - $this->mParams[$name] = array( 'desc' => $description, 'require' => $required, 'withArg' => $withArg ); |
| 166 | + protected function addOption( $name, $description, $required = false, $withArg = false, $shortName = false ) { |
| 167 | + $this->mParams[$name] = array( 'desc' => $description, 'require' => $required, 'withArg' => $withArg, 'shortName' => $shortName ); |
| 168 | + if ( $shortName !== false ) { |
| 169 | + $this->mShortParamsMap[$shortName] = $name; |
| 170 | + } |
164 | 171 | } |
165 | 172 | |
166 | 173 | /** |
— | — | @@ -391,8 +398,8 @@ |
392 | 399 | |
393 | 400 | # Generic (non script dependant) options: |
394 | 401 | |
395 | | - $this->addOption( 'help', 'Display this help message' ); |
396 | | - $this->addOption( 'quiet', 'Whether to supress non-error output' ); |
| 402 | + $this->addOption( 'help', 'Display this help message', false, false, 'h' ); |
| 403 | + $this->addOption( 'quiet', 'Whether to supress non-error output', false, false, 'q' ); |
397 | 404 | $this->addOption( 'conf', 'Location of LocalSettings.php, if not default', false, true ); |
398 | 405 | $this->addOption( 'wiki', 'For specifying the wiki ID', false, true ); |
399 | 406 | $this->addOption( 'globals', 'Output globals at the end of processing for debugging' ); |
— | — | @@ -607,6 +614,9 @@ |
608 | 615 | # Short options |
609 | 616 | for ( $p = 1; $p < strlen( $arg ); $p++ ) { |
610 | 617 | $option = $arg { $p } ; |
| 618 | + if ( !isset( $this->mParams[$option] ) && isset( $this->mShortParamsMap[$option] ) ) { |
| 619 | + $option = $this->mShortParamsMap[$option]; |
| 620 | + } |
611 | 621 | if ( isset( $this->mParams[$option]['withArg'] ) && $this->mParams[$option]['withArg'] ) { |
612 | 622 | $param = next( $argv ); |
613 | 623 | if ( $param === false ) { |
— | — | @@ -719,6 +729,9 @@ |
720 | 730 | // Generic parameters |
721 | 731 | $this->output( "Generic maintenance parameters:\n" ); |
722 | 732 | foreach ( $this->mGenericParameters as $par => $info ) { |
| 733 | + if ( $info['shortName'] !== false ) { |
| 734 | + $par .= " (-{$info['shortName']})"; |
| 735 | + } |
723 | 736 | $this->output( |
724 | 737 | wordwrap( "$tab--$par: " . $info['desc'], $descWidth, |
725 | 738 | "\n$tab$tab" ) . "\n" |
— | — | @@ -731,6 +744,9 @@ |
732 | 745 | $this->output( "Script dependant parameters:\n" ); |
733 | 746 | // Parameters description |
734 | 747 | foreach ( $scriptDependantParams as $par => $info ) { |
| 748 | + if ( $info['shortName'] !== false ) { |
| 749 | + $par .= " (-{$info['shortName']})"; |
| 750 | + } |
735 | 751 | $this->output( |
736 | 752 | wordwrap( "$tab--$par: " . $info['desc'], $descWidth, |
737 | 753 | "\n$tab$tab" ) . "\n" |
— | — | @@ -753,6 +769,9 @@ |
754 | 770 | $this->output( "Script specific parameters:\n" ); |
755 | 771 | // Parameters description |
756 | 772 | foreach ( $scriptSpecificParams as $par => $info ) { |
| 773 | + if ( $info['shortName'] !== false ) { |
| 774 | + $par .= " (-{$info['shortName']})"; |
| 775 | + } |
757 | 776 | $this->output( |
758 | 777 | wordwrap( "$tab--$par: " . $info['desc'], $descWidth, |
759 | 778 | "\n$tab$tab" ) . "\n" |