From f505f3577fb28c3ccf0440f5a17a00942b8a7491 Mon Sep 17 00:00:00 2001 From: Muah Date: Wed, 15 Feb 2017 13:14:34 +0200 Subject: [PATCH] Add helper info for the util command --- modules/system/console/OctoberUtil.php | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) 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".'], ]; }