mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Doing some fixes as the longest option + a short would cause incorrect formatting.
This commit is contained in:
parent
0eb68226ce
commit
09adc38b6c
2 changed files with 9 additions and 7 deletions
|
@ -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) {
|
||||
|
|
|
@ -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');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue