Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 797a29b

Browse files
cleanup on command help init and unit test
1 parent 8b32e26 commit 797a29b

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

‎src/Options.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public function __construct(Colors $colors = null)
4949
'' => array(
5050
'opts' => array(),
5151
'args' => array(),
52-
'help' => ''
52+
'help' => '',
53+
'commandhelp' => 'This tool accepts a command as first parameter as outlined below:'
5354
)
5455
); // default command
5556

@@ -352,8 +353,8 @@ public function help()
352353
$text = '';
353354

354355
$hascommands = (count($this->setup) > 1);
355-
$commandhelp = $this->setup[""]["commandhelp"]
356-
?: 'This tool accepts a command as first parameter as outlined below:';
356+
$commandhelp = $this->setup['']["commandhelp"];
357+
357358
foreach ($this->setup as $command => $config) {
358359
$hasopts = (bool)$this->setup[$command]['opts'];
359360
$hasargs = (bool)$this->setup[$command]['args'];

‎tests/OptionsTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,15 @@ function test_complex()
7676
$this->assertTrue($options->getOpt('long'));
7777
$this->assertEquals(array('foo'), $options->args);
7878
}
79+
80+
function test_commandhelp()
81+
{
82+
$options = new Options();
83+
$options->registerCommand('cmd', 'a command');
84+
$this->assertStringContainsString('accepts a command as first parameter', $options->help());
85+
86+
$options->setCommandHelp('foooooobaar');
87+
$this->assertStringNotContainsString('accepts a command as first parameter', $options->help());
88+
$this->assertStringContainsString('foooooobaar', $options->help());
89+
}
7990
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /