mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Add helper info for the util command
This commit is contained in:
parent
5aa351f67c
commit
f505f3577f
@ -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".'],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user