From 20850d5e33001fcfe20ab39437d570f8dea80346 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Mon, 18 Jul 2011 03:30:03 +0000 Subject: [PATCH] Disallow given options twice (instead of letting the newest one take precedence). This property may be useful for a Het Deploy wrapper. --- maintenance/Maintenance.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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; -- 2.20.1