Doing some fixes as the longest option + a short would cause incorrect formatting.

This commit is contained in:
mark_story 2010-10-09 12:53:38 -04:00
parent 0eb68226ce
commit 09adc38b6c
2 changed files with 9 additions and 7 deletions

View file

@ -278,7 +278,7 @@ class ConsoleOptionParser {
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) {

View file

@ -230,19 +230,21 @@ class ConsoleOptionParserTest extends CakeTestCase {
*/
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');
}