diff --git a/modules/system/console/OctoberUtil.php b/modules/system/console/OctoberUtil.php index 5211b97be..5dd2a0d0e 100644 --- a/modules/system/console/OctoberUtil.php +++ b/modules/system/console/OctoberUtil.php @@ -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('Utility command "%s" does not exist!', $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".'], ]; }