Skip to content

Commit

Permalink
Fixing incorrectly inflected shell names in help.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Aug 6, 2011
1 parent 5f84b48 commit fb756c5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/Cake/Console/ConsoleOptionParser.php
Expand Up @@ -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',
Expand Down Expand Up @@ -206,7 +206,7 @@ public static function buildFromArray($spec) {
*/
public function command($text = null) {
if ($text !== null) {
$this->_command = $text;
$this->_command = Inflector::underscore($text);
return $this;
}
return $this->_command;
Expand Down
12 changes: 11 additions & 1 deletion lib/Cake/Test/Case/Console/ConsoleOptionParserTest.php
Expand Up @@ -496,6 +496,16 @@ public function testCreateFactory() {
$this->assertEquals('factory', $parser->command());
}

/**
* 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.
Expand Down Expand Up @@ -529,4 +539,4 @@ public function testParsingWithSubParser() {
$this->assertEquals($expected, $result, 'Sub parser did not parse request.');
}

}
}

0 comments on commit fb756c5

Please sign in to comment.