Skip to content

Commit

Permalink
FEATURE: Introduce help flag option for existing CLI commands
Browse files Browse the repository at this point in the history
  • Loading branch information
crydotsnake committed Sep 1, 2024
1 parent af3481b commit b1af6ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Neos.Flow/Classes/Cli/RequestBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ public function build($commandLine): Request
$request = new Request();
$request->setControllerObjectName(HelpCommandController::class);

// @TODO: Can this be implemented even better/cleaner?
if (in_array('--help', $commandLine)) {
$request->setControllerCommandName('help');
$request->setArguments(['commandIdentifier' => $commandLine[0]]);
$request->setControllerObjectName(HelpCommandController::class);
return $request;
}

if (is_array($commandLine) === true) {
$rawCommandLineArguments = $commandLine;
} else {
Expand Down
2 changes: 2 additions & 0 deletions Neos.Flow/Classes/Command/HelpCommandController.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ protected function displayHelpForCommand(Command $command)
foreach ($optionDescriptions as $optionDescription) {
$this->outputLine($optionDescription);
}
$this->outputLine('--help');
$this->outputLine('Shows information about the specific command and which parameters are available');
}

if ($command->getDescription() !== '') {
Expand Down

0 comments on commit b1af6ca

Please sign in to comment.