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) {
|
foreach ($this->_options as $description) {
|
||||||
$max = (strlen($description['name']) > $max) ? strlen($description['name']) : $max;
|
$max = (strlen($description['name']) > $max) ? strlen($description['name']) : $max;
|
||||||
}
|
}
|
||||||
$max += 3;
|
$max += 6;
|
||||||
$out[] = '<info>Options:</info>';
|
$out[] = '<info>Options:</info>';
|
||||||
$out[] = '';
|
$out[] = '';
|
||||||
foreach ($this->_options as $description) {
|
foreach ($this->_options as $description) {
|
||||||
|
|
|
@ -230,19 +230,21 @@ class ConsoleOptionParserTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
function testGetHelpWithOptions() {
|
function testGetHelpWithOptions() {
|
||||||
$parser = new ConsoleOptionParser('mycommand', false);
|
$parser = new ConsoleOptionParser('mycommand', false);
|
||||||
$parser->addOption('test', array('short' => 't', 'help' => 'A test option.'))
|
$parser->addOption('test', array('help' => 'A test option.'))
|
||||||
->addOption('connection', array('help' => 'The connection to use.', 'default' => 'default'));
|
->addOption('connection', array(
|
||||||
|
'short' => 'c', 'help' => 'The connection to use.', 'default' => 'default'
|
||||||
|
));
|
||||||
|
|
||||||
$result = $parser->help();
|
$result = $parser->help();
|
||||||
$expected = <<<TEXT
|
$expected = <<<TEXT
|
||||||
<info>Usage:</info>
|
<info>Usage:</info>
|
||||||
cake mycommand [-h] [-t] [--connection default]
|
cake mycommand [-h] [--test] [-c default]
|
||||||
|
|
||||||
<info>Options:</info>
|
<info>Options:</info>
|
||||||
|
|
||||||
--help, -h Display this help.
|
--help, -h Display this help.
|
||||||
--test, -t A test option.
|
--test A test option.
|
||||||
--connection The connection to use. <comment>(default: default)</comment>
|
--connection, -c The connection to use. <comment>(default: default)</comment>
|
||||||
TEXT;
|
TEXT;
|
||||||
$this->assertEquals($expected, $result, 'Help does not match');
|
$this->assertEquals($expected, $result, 'Help does not match');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue