Skip to content

Commit b47e8a5

Browse files
committed
bug fixed for no description for closure command. add command message error.
1 parent 0711cb7 commit b47e8a5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Application.php

+6
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,12 @@ public function runCommand($name, $believable = false)
322322
$handler = $this->commands[$name];
323323

324324
if (\is_object($handler) && method_exists($handler, '__invoke')) {
325+
if ($this->input->getSameOpt(['h', 'help'])) {
326+
$des = $this->getCommandMessage($name, 'No command description message.');
327+
328+
return $this->output->write($des);
329+
}
330+
325331
$status = $handler($this->input, $this->output);
326332
} else {
327333
if (!class_exists($handler)) {

src/Base/AbstractApplication.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
use Inhere\Console\Traits\SimpleEventTrait;
1515
use Inhere\Console\Style\Style;
1616
use Inhere\Console\Utils\FormatUtil;
17-
use Inhere\Console\Utils\Helper;
1817

1918
/**
2019
* Class AbstractApplication
@@ -471,7 +470,7 @@ public function getCommandMessage($name, $default = null)
471470
*/
472471
public function addCommandMessage($name, $message)
473472
{
474-
if (!$name || !$message) {
473+
if ($name && $message) {
475474
$this->commandMessages[$name] = $message;
476475
}
477476

0 commit comments

Comments
 (0)