Skip to content

Commit 06bc667

Browse files
committed
fixed for alone command description message dispaly on use -h
1 parent 3763ffd commit 06bc667

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/Base/AbstractCommand.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,11 @@ protected function setAnnotationVar(string $name, $value)
365365
*/
366366
protected function parseAnnotationVars($str)
367367
{
368+
// not use vars
369+
if (false === strpos($str, '{')) {
370+
return $str;
371+
}
372+
368373
static $map;
369374

370375
if ($map === null) {
@@ -374,11 +379,6 @@ protected function parseAnnotationVars($str)
374379
}
375380
}
376381

377-
// not use vars
378-
if (false === strpos($str, '{')) {
379-
return $str;
380-
}
381-
382382
return $map ? strtr($str, $map) : $str;
383383
}
384384

@@ -393,6 +393,7 @@ protected function showHelpByMethodAnnotations($method, $action = null, array $a
393393
{
394394
$ref = new \ReflectionClass($this);
395395
$name = $this->input->getCommand();
396+
$isAlone = $ref->isSubclassOf(CommandInterface::class);
396397

397398
if (!$ref->hasMethod($method)) {
398399
$this->write("The command [<info>$name</info>] don't exist in the group: " . static::getName());
@@ -422,6 +423,12 @@ protected function showHelpByMethodAnnotations($method, $action = null, array $a
422423

423424
$msg = trim($tags[$tag]);
424425
$tag = ucfirst($tag);
426+
427+
// for alone command
428+
if (!$msg && $tag === 'description' && $isAlone) {
429+
$msg = self::getDescription();
430+
}
431+
425432
$help[] = "<comment>$tag:</comment>\n $msg\n";
426433
}
427434

0 commit comments

Comments
 (0)