Skip to content

Commit

Permalink
Doing some fixes as the longest option + a short would cause incorrec…
Browse files Browse the repository at this point in the history
…t formatting.
  • Loading branch information
markstory committed Oct 14, 2010
1 parent 0eb6822 commit 09adc38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cake/console/console_option_parser.php
Expand Up @@ -278,7 +278,7 @@ public function help() {
foreach ($this->_options as $description) {
$max = (strlen($description['name']) > $max) ? strlen($description['name']) : $max;
}
$max += 3;
$max += 6;
$out[] = '<info>Options:</info>';
$out[] = '';
foreach ($this->_options as $description) {
Expand Down
14 changes: 8 additions & 6 deletions cake/tests/cases/console/console_option_parser.test.php
Expand Up @@ -230,19 +230,21 @@ function testPositionalArgNotEnough() {
*/
function testGetHelpWithOptions() {
$parser = new ConsoleOptionParser('mycommand', false);
$parser->addOption('test', array('short' => 't', 'help' => 'A test option.'))
->addOption('connection', array('help' => 'The connection to use.', 'default' => 'default'));
$parser->addOption('test', array('help' => 'A test option.'))
->addOption('connection', array(
'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default'
));

$result = $parser->help();
$expected = <<<TEXT
<info>Usage:</info>
cake mycommand [-h] [-t] [--connection default]
cake mycommand [-h] [--test] [-c default]
<info>Options:</info>
--help, -h Display this help.
--test, -t A test option.
--connection The connection to use. <comment>(default: default)</comment>
--help, -h Display this help.
--test A test option.
--connection, -c The connection to use. <comment>(default: default)</comment>
TEXT;
$this->assertEquals($expected, $result, 'Help does not match');
}
Expand Down

0 comments on commit 09adc38

Please sign in to comment.