Fixing incorrectly inflected shell names in help.

This commit is contained in:
Mark Story 2011-08-06 09:52:07 -04:00
parent 5f84b4846c
commit fb756c5aee
2 changed files with 13 additions and 3 deletions

View file

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

View file

@ -496,6 +496,16 @@ TEXT;
$this->assertEquals('factory', $parser->command()); $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 * test that parse() takes a subcommand argument, and that the subcommand parser
* is used. * is used.