cvs: peardoc / configure.php

From: Date: Tue, 10 Feb 2009 18:15:41 +0000
Subject: cvs: peardoc / configure.php
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-11541@lists.php.net to get a copy of this message
cweiske Tue Feb 10 18:15:41 2009 UTC Modified files: /peardoc configure.php Log: Add --quiet parameter http://cvs.php.net/viewvc.cgi/peardoc/configure.php?r1=1.10&r2=1.11&diff_format=u Index: peardoc/configure.php diff -u peardoc/configure.php:1.10 peardoc/configure.php:1.11 --- peardoc/configure.php:1.10 Tue Feb 10 06:27:05 2009 +++ peardoc/configure.php Tue Feb 10 18:15:40 2009 @@ -14,6 +14,7 @@ $opts = parseArgs(); $GLOBALS['display_verbose'] = $opts['verbose']; $GLOBALS['errorcode'] = 0; +$GLOBALS['quiet'] = $opts['quiet']; if (empty($opts['manual_file'])) { $opts['manual_file'] = 'manual.xml'; } @@ -38,8 +39,8 @@ . ' -d ' . $opts['giant_file'] ); } catch (Exception $e) { - logMsg('Exception:'); - logMsg($e->getMessage()); + logErr('Exception:'); + logErr($e->getMessage()); } @@ -57,7 +58,7 @@ require_once 'Console/CommandLine.php'; $parser = new Console_CommandLine(array( 'description' => 'configure the pear manual build', - 'version' => '$Id: configure.php,v 1.10 2009/02/10 06:27:05 cweiske Exp $' + 'version' => '$Id: configure.php,v 1.11 2009/02/10 18:15:40 cweiske Exp $' )); $parser->addOption('verbose', array( @@ -67,6 +68,13 @@ 'description' => 'Display detailled messages', 'default' => false )); + $parser->addOption('quiet', array( + 'short_name' => '-q', + 'long_name' => '--quiet', + 'action' => 'StoreTrue', + 'description' => 'Hide all non-error messages', + 'default' => false + )); $parser->addOption('validate', array( 'short_name' => '-n', 'long_name' => '--no-validate', @@ -270,12 +278,12 @@ $msg = ob_get_clean(); if ($msg) { $GLOBALS['errorcode'] = 3; - logMsg(' There were warnings loading the manual'); + logErr(' There were warnings loading the manual'); } } if (!$bLoaded) { if (isset($msg) && $msg) { - logMsg($msg); + logErr($msg); } $GLOBALS['errorcode'] = 4; throw new Exception('Failed to load manual.xml'); @@ -291,10 +299,10 @@ $msg = ob_get_clean(); } if (!$bValid) { - logMsg(' Manual has errors. Use'); - logMsg(' xmllint --valid --noout ' . $strManual); - logMsg(' xmllint --valid --noout ' . $strGiant); - logMsg(' to get detailled error messages.'); + logErr(' Manual has errors. Use'); + logErr(' xmllint --valid --noout ' . $strManual); + logErr(' xmllint --valid --noout ' . $strGiant); + logErr(' to get detailled error messages.'); $GLOBALS['errorcode'] = 5; } @@ -305,16 +313,35 @@ /** * Just log a message to stdout. * +* @param string $msg Message to display * @param boolean $bVerbose Mark message as "verbose", so that it's only shown * --verbose has been passed as option to the script +* @param boolean $bError Mark message as "error" so that it gets displayed +* even when --quiet is used. * * @return void */ -function logMsg($msg, $bVerbose = false) +function logMsg($msg, $bVerbose = false, $bError = false) { + if ($GLOBALS['quiet'] && !$bError) { + return; + } if (!$bVerbose || $GLOBALS['display_verbose']) { echo $msg . "\n"; } } +/** +* Log an error. +* Shortcut for logMsg() +* +* @param string $msg Message to display +* +* @return void +*/ +function logErr($msg) +{ + logMsg($msg, false, true); +} + ?> \ No newline at end of file

« previous php.pear.doc (#11541) next »