[console] Use the description when no help is available

This commit is contained in:
Tristan Darricau 2015-08-24 15:16:17 +02:00
parent 9962f36f97
commit e5d3f2567d
4 changed files with 5 additions and 3 deletions

View File

@ -484,7 +484,7 @@ class Command
*/ */
public function getHelp() public function getHelp()
{ {
return $this->help; return $this->help ?: $this->description;
} }
/** /**

View File

@ -131,6 +131,8 @@ class CommandTest extends \PHPUnit_Framework_TestCase
$ret = $command->setHelp('help1'); $ret = $command->setHelp('help1');
$this->assertEquals($command, $ret, '->setHelp() implements a fluent interface'); $this->assertEquals($command, $ret, '->setHelp() implements a fluent interface');
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help'); $this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
$command->setHelp('');
$this->assertEquals('description', $command->getHelp(), '->getHelp() fallback to the description');
} }
public function testGetProcessedHelp() public function testGetProcessedHelp()

View File

@ -97,7 +97,7 @@
<command id="foo:bar" name="foo:bar"> <command id="foo:bar" name="foo:bar">
<usage>foo:bar</usage> <usage>foo:bar</usage>
<description>The foo:bar command</description> <description>The foo:bar command</description>
<help/> <help>The foo:bar command</help>
<aliases> <aliases>
<alias>afoobar</alias> <alias>afoobar</alias>
</aliases> </aliases>

View File

@ -4,7 +4,7 @@
<command id="foo:bar" name="foo:bar"> <command id="foo:bar" name="foo:bar">
<usage>foo:bar</usage> <usage>foo:bar</usage>
<description>The foo:bar command</description> <description>The foo:bar command</description>
<help/> <help>The foo:bar command</help>
<aliases> <aliases>
<alias>afoobar</alias> <alias>afoobar</alias>
</aliases> </aliases>