Skip to content

Commit 09adc38

Browse files
committed
Doing some fixes as the longest option + a short would cause incorrect formatting.
1 parent 0eb6822 commit 09adc38

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

cake/console/console_option_parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ public function help() {
278278
foreach ($this->_options as $description) {
279279
$max = (strlen($description['name']) > $max) ? strlen($description['name']) : $max;
280280
}
281-
$max += 3;
281+
$max += 6;
282282
$out[] = '<info>Options:</info>';
283283
$out[] = '';
284284
foreach ($this->_options as $description) {

cake/tests/cases/console/console_option_parser.test.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,19 +230,21 @@ function testPositionalArgNotEnough() {
230230
*/
231231
function testGetHelpWithOptions() {
232232
$parser = new ConsoleOptionParser('mycommand', false);
233-
$parser->addOption('test', array('short' => 't', 'help' => 'A test option.'))
234-
->addOption('connection', array('help' => 'The connection to use.', 'default' => 'default'));
233+
$parser->addOption('test', array('help' => 'A test option.'))
234+
->addOption('connection', array(
235+
'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default'
236+
));
235237

236238
$result = $parser->help();
237239
$expected = <<<TEXT
238240
<info>Usage:</info>
239-
cake mycommand [-h] [-t] [--connection default]
241+
cake mycommand [-h] [--test] [-c default]
240242
241243
<info>Options:</info>
242244
243-
--help, -h Display this help.
244-
--test, -t A test option.
245-
--connection The connection to use. <comment>(default: default)</comment>
245+
--help, -h Display this help.
246+
--test A test option.
247+
--connection, -c The connection to use. <comment>(default: default)</comment>
246248
TEXT;
247249
$this->assertEquals($expected, $result, 'Help does not match');
248250
}

0 commit comments

Comments
 (0)