From: Aaron Schulz Date: Mon, 18 Jul 2011 03:30:03 +0000 (+0000) Subject: Disallow given options twice (instead of letting the newest one take precedence)... X-Git-Tag: 1.31.0-rc.0~28779 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/membres/fiche.php?a=commitdiff_plain;h=20850d5e33001fcfe20ab39437d570f8dea80346;p=lhc%2Fweb%2Fwiklou.git Disallow given options twice (instead of letting the newest one take precedence). This property may be useful for a Het Deploy wrapper. --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 7d5385412d..0889df9e46 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -597,10 +597,14 @@ abstract class Maintenance { } elseif ( substr( $arg, 0, 2 ) == '--' ) { # Long options $option = substr( $arg, 2 ); + if ( array_key_exists( $option, $options ) ) { + $this->error( "\nERROR: $option parameter given twice\n" ); + $this->maybeHelp( true ); + } if ( isset( $this->mParams[$option] ) && $this->mParams[$option]['withArg'] ) { $param = next( $argv ); if ( $param === false ) { - $this->error( "\nERROR: $option needs a value after it\n" ); + $this->error( "\nERROR: $option parameter needs a value after it\n" ); $this->maybeHelp( true ); } $options[$option] = $param; @@ -621,10 +625,14 @@ abstract class Maintenance { if ( !isset( $this->mParams[$option] ) && isset( $this->mShortParamsMap[$option] ) ) { $option = $this->mShortParamsMap[$option]; } + if ( array_key_exists( $option, $options ) ) { + $this->error( "\nERROR: $option parameter given twice\n" ); + $this->maybeHelp( true ); + } if ( isset( $this->mParams[$option]['withArg'] ) && $this->mParams[$option]['withArg'] ) { $param = next( $argv ); if ( $param === false ) { - $this->error( "\nERROR: $option needs a value after it\n" ); + $this->error( "\nERROR: $option parameter needs a value after it\n" ); $this->maybeHelp( true ); } $options[$option] = $param;