Browse Source

Fixing incorrectly inflected shell names in help.

Mark Story 14 years ago
parent
commit
fb756c5aee

+ 2 - 2
lib/Cake/Console/ConsoleOptionParser.php

@@ -124,7 +124,7 @@ class ConsoleOptionParser {
  *  this to false will prevent the addition of `--verbose` & `--quiet` options.
  */
 	public function __construct($command = null, $defaultOptions = true) {
-		$this->_command = $command;
+		$this->command($command);
 
 		$this->addOption('help', array(
 			'short' => 'h',
@@ -206,7 +206,7 @@ class ConsoleOptionParser {
  */
 	public function command($text = null) {
 		if ($text !== null) {
-			$this->_command = $text;
+			$this->_command = Inflector::underscore($text);
 			return $this;
 		}
 		return $this->_command;

+ 11 - 1
lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php

@@ -497,6 +497,16 @@ TEXT;
 	}
 
 /**
+ * test that command() inflects the command name.
+ *
+ * @return void
+ */
+	public function testCommandInflection() {
+		$parser = new ConsoleOptionParser('CommandLine');
+		$this->assertEquals('command_line', $parser->command());
+	}
+
+/**
  * test that parse() takes a subcommand argument, and that the subcommand parser
  * is used.
  *
@@ -529,4 +539,4 @@ TEXT;
 		$this->assertEquals($expected, $result, 'Sub parser did not parse request.');
 	}
 
-}
+}