bug #15601 [console] Use the description when no help is available (Nicofuma)

This PR was merged into the 2.3 branch.

Discussion
----------

[console] Use the description when no help is available

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #15498
| License       | MIT
| Doc PR        |

Commits
-------

e5d3f25 [console] Use the description when no help is available
This commit is contained in:
Fabien Potencier 2015-08-31 14:48:21 +02:00
commit cb303017b4
4 changed files with 5 additions and 3 deletions

View File

@ -484,7 +484,7 @@ class Command
*/
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');
$this->assertEquals($command, $ret, '->setHelp() implements a fluent interface');
$this->assertEquals('help1', $command->getHelp(), '->setHelp() sets the help');
$command->setHelp('');
$this->assertEquals('description', $command->getHelp(), '->getHelp() fallback to the description');
}
public function testGetProcessedHelp()

View File

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

View File

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