Skip to content

Commit

Permalink
fix(cmd.help): usage label was printed even if no text
Browse files Browse the repository at this point in the history
  • Loading branch information
adhocore committed Jan 2, 2020
1 parent 9cac890 commit 4639624
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Helper/OutputHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ protected function showHelp(string $for, array $items, string $header = '', stri
*
* It replaces $0 with actual command name and properly pads ` ## ` segments.
*
* @param string|null $usage Usage description.
* @param string $usage Usage description.
*
* @return self
*/
public function showUsage(string $usage = null): self
public function showUsage(string $usage): self
{
$usage = \str_replace('$0', $_SERVER['argv'][0] ?? '[cmd]', $usage);

Expand Down
7 changes: 5 additions & 2 deletions src/Input/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,11 @@ public function showHelp()

$helper
->showArgumentsHelp($this->allArguments())
->showOptionsHelp($this->allOptions(), '', 'Legend: <required> [optional] variadic...')
->showUsage($this->_usage);
->showOptionsHelp($this->allOptions(), '', 'Legend: <required> [optional] variadic...');

if ($this->_usage) {
$helper->showUsage($this->_usage);
}

return $this->emit('_exit', 0);
}
Expand Down

0 comments on commit 4639624

Please sign in to comment.