Browse Source

Allow buildFromArray() to not set defaults.
Remove undocumented true param.

euromark 11 years ago
parent
commit
69bce9b928
1 changed files with 7 additions and 4 deletions
  1. 7 4
      src/Console/ConsoleOptionParser.php

+ 7 - 4
src/Console/ConsoleOptionParser.php

@@ -184,10 +184,11 @@ class ConsoleOptionParser {
  * }}}
  *
  * @param array $spec The spec to build the OptionParser with.
+ * @param bool $defaultOptions Whether you want the verbose and quiet options set.
  * @return ConsoleOptionParser
  */
-	public static function buildFromArray($spec) {
-		$parser = new ConsoleOptionParser($spec['command']);
+	public static function buildFromArray($spec, $defaultOptions = true) {
+		$parser = new ConsoleOptionParser($spec['command'], $defaultOptions);
 		if (!empty($spec['arguments'])) {
 			$parser->addArguments($spec['arguments']);
 		}
@@ -593,10 +594,12 @@ class ConsoleOptionParser {
 			$subparser->command($this->command() . ' ' . $subparser->command());
 			return $subparser->help(null, $format, $width);
 		}
+
 		$formatter = new HelpFormatter($this);
-		if ($format === 'text' || $format === true) {
+		if ($format === 'text') {
 			return $formatter->text($width);
-		} elseif ($format === 'xml') {
+		}
+		if ($format === 'xml') {
 			return $formatter->xml();
 		}
 	}