Add helper info for the util command

This commit is contained in:
Muah 2017-02-15 13:14:34 +02:00 committed by Samuel Georges
parent 5aa351f67c
commit f505f3577f

View File

@ -53,8 +53,25 @@ class OctoberUtil extends Command
$command = implode(' ', (array) $this->argument('name'));
$method = 'util'.studly_case($command);
$methods = preg_grep('/^util/', get_class_methods(get_called_class()));
$list = array_map(function($item){
return "october:".snake_case($item, " ");
},$methods);
if (!$this->argument('name')) {
$message = 'There are no commands defined in the "util" namespace.';
if (1 == count($list)) {
$message .= "\n\nDid you mean this?\n ";
} else {
$message .= "\n\nDid you mean one of these?\n ";
}
$message .= implode("\n ", $list);
throw new \InvalidArgumentException($message);
}
if (!method_exists($this, $method)) {
$this->error(sprintf('<error>Utility command "%s" does not exist!</error>', $command));
$this->error(sprintf('Utility command "%s" does not exist!', $command));
return;
}
@ -68,7 +85,7 @@ class OctoberUtil extends Command
protected function getArguments()
{
return [
['name', InputArgument::IS_ARRAY, 'A utility command to perform.'],
['name', InputArgument::IS_ARRAY, 'The utility command to perform, For more info "http://octobercms.com/docs/console/commands#october-util-command".'],
];
}