From 700657227f3d7a07e6ce959c896f9a5f5f4a6aed Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 18 Oct 2004 08:11:06 +0000 Subject: [PATCH] Clean up options code a bit to make use of commandLine.inc's parsing --- maintenance/parserTests.php | 43 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/maintenance/parserTests.php b/maintenance/parserTests.php index fd536b39e2..b52e7e5e09 100644 --- a/maintenance/parserTests.php +++ b/maintenance/parserTests.php @@ -25,7 +25,8 @@ */ /** */ -$optionsWithArgs = array('regex'); +$options = array( 'quick', 'color' ); +$optionsWithArgs = array( 'regex' ); require_once( 'commandLine.inc' ); require_once( 'languages/LanguageUtf8.php' ); @@ -52,33 +53,31 @@ class ParserTest { */ function ParserTest() { global $options; + + # Only colorize output if stdout is a terminal. $this->lightcolor = false; - if( isset( $_SERVER['argv'] ) && in_array( '--color', $_SERVER['argv'] ) ) { - $this->color = true; - } elseif( isset( $_SERVER['argv'] ) && in_array( '--color=yes', $_SERVER['argv'] ) ) { - $this->color = true; - } elseif( isset( $_SERVER['argv'] ) && in_array( '--color=light', $_SERVER['argv'] ) ) { - $this->color = true; - $this->lightcolor = true; - } elseif( isset( $_SERVER['argv'] ) && in_array( '--color=no', $_SERVER['argv'] ) ) { - $this->color = false; - } elseif( wfIsWindows() ) { - $this->color = false; - } else { - # Only colorize output if stdout is a terminal. - $this->color = posix_isatty(1); - } + $this->color = !wfIsWindows() && posix_isatty(1); - if( isset( $_SERVER['argv'] ) && in_array( '--quick', $_SERVER['argv'] ) ) { - $this->showDiffs = false; - } else { - $this->showDiffs = true; + if( isset( $options['color'] ) ) { + switch( $options['color'] ) { + case 'no': + $this->color = false; + break; + case 'light': + $this->lightcolor = true; + # Fall through + case 'yes': + default: + $this->color = true; + break; + } } + + $this->showDiffs = !isset( $options['quick'] ); if (isset($options['regex'])) { $this->regex = $options['regex']; - } - else { + } else { # Matches anything $this->regex = ''; } -- 2.20.1