diff --git a/Neos.Flow/Classes/Cli/RequestBuilder.php b/Neos.Flow/Classes/Cli/RequestBuilder.php index f017f23677..df1ee24411 100644 --- a/Neos.Flow/Classes/Cli/RequestBuilder.php +++ b/Neos.Flow/Classes/Cli/RequestBuilder.php @@ -140,14 +140,23 @@ public function build($commandLine): Request } } } - if (count($rawCommandLineArguments) === 0) { + $firstArgument = count($rawCommandLineArguments) ? trim(array_shift($rawCommandLineArguments)) : null; + if ( + $firstArgument === null + || $firstArgument === '--help' + ) { $request->setControllerCommandName('helpStub'); return $request; } - $commandIdentifier = trim(array_shift($rawCommandLineArguments)); + if (in_array('--help', $rawCommandLineArguments, true)) { + $request->setControllerCommandName('help'); + $request->setArguments(['commandIdentifier' => $firstArgument]); + return $request; + } + try { - $command = $this->commandManager->getCommandByIdentifier($commandIdentifier); + $command = $this->commandManager->getCommandByIdentifier($firstArgument); } catch (CommandException $exception) { $request->setArgument('exception', $exception); $request->setControllerCommandName('error'); @@ -188,6 +197,9 @@ protected function parseRawCommandLineArguments(array $rawCommandLineArguments, $requiredArguments = []; $optionalArguments = []; foreach ($commandMethodParameters as $parameterName => $parameterInfo) { + if ($parameterName === 'help') { + throw new \RuntimeException(sprintf('The option --help is reserved in %s::%s', $controllerObjectName, $commandMethodName), 1730715152); + } if ($parameterInfo['optional'] === false) { $requiredArguments[strtolower($parameterName)] = [ 'parameterName' => $parameterName, diff --git a/Neos.Flow/Classes/Command/HelpCommandController.php b/Neos.Flow/Classes/Command/HelpCommandController.php index 924c6670a8..e3eeadbdd3 100644 --- a/Neos.Flow/Classes/Command/HelpCommandController.php +++ b/Neos.Flow/Classes/Command/HelpCommandController.php @@ -124,7 +124,7 @@ protected function displayHelpIndex() $this->outputLine('* = compile time command'); $this->outputLine(); - $this->outputLine('See "%s help " for more information about a specific command.', [$this->getFlowInvocationString()]); + $this->outputLine('Use "%s [command] --help" for more information about a command.', [$this->getFlowInvocationString()]); $this->outputLine(); } @@ -212,6 +212,7 @@ protected function displayHelpForCommand(Command $command) if (count($optionDescriptions) > 0) { $this->outputLine(); $this->outputLine('OPTIONS:'); + $optionDescriptions[] = vsprintf(' %-20s %s', ['--help', 'Shows detailed information about this command']); foreach ($optionDescriptions as $optionDescription) { $this->outputLine($optionDescription); } @@ -260,7 +261,7 @@ public function errorCommand(CommandException $exception) } $this->outputLine(); $this->outputLine('Enter "%s help" for an overview of all available commands', [$this->getFlowInvocationString()]); - $this->outputLine('or "%s help " for a detailed description of the corresponding command.', [$this->getFlowInvocationString()]); + $this->outputLine('or "%s --help" for a detailed description of the corresponding command.', [$this->getFlowInvocationString()]); $this->quit(1); }