Skip to content

Commit

Permalink
bug fixed for no description for closure command. add command message…
Browse files Browse the repository at this point in the history
… error.
  • Loading branch information
inhere committed Dec 18, 2017
1 parent 0711cb7 commit b47e8a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 6 additions & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,12 @@ public function runCommand($name, $believable = false)
$handler = $this->commands[$name];

if (\is_object($handler) && method_exists($handler, '__invoke')) {
if ($this->input->getSameOpt(['h', 'help'])) {
$des = $this->getCommandMessage($name, 'No command description message.');

return $this->output->write($des);
}

$status = $handler($this->input, $this->output);
} else {
if (!class_exists($handler)) {
Expand Down
3 changes: 1 addition & 2 deletions src/Base/AbstractApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Inhere\Console\Traits\SimpleEventTrait;
use Inhere\Console\Style\Style;
use Inhere\Console\Utils\FormatUtil;
use Inhere\Console\Utils\Helper;

/**
* Class AbstractApplication
Expand Down Expand Up @@ -471,7 +470,7 @@ public function getCommandMessage($name, $default = null)
*/
public function addCommandMessage($name, $message)
{
if (!$name || !$message) {
if ($name && $message) {
$this->commandMessages[$name] = $message;
}

Expand Down

0 comments on commit b47e8a5

Please sign in to comment.