-
-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FEATURE: Introduce --help flag option for existing CLI commands #3367
FEATURE: Introduce --help flag option for existing CLI commands #3367
Conversation
Open TODOsI'm still thinking about if i could implement this better. Also i still have to think about how to improve the description for the And also the tests needs to be adjusted. |
As it is not possible to combine |
@@ -118,6 +118,14 @@ public function build($commandLine): Request | |||
$request = new Request(); | |||
$request->setControllerObjectName(HelpCommandController::class); | |||
|
|||
// @TODO: Can this be implemented even better/cleaner? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really see how, AFAIK we do not have a concept for such global things, but I'd say whatever next thing we want to implement that is global (-v(v(v)) maybe???) we can then think about a better structure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it, pretty simple really, I would approve but wonder if we shouldn't safeguard users who actually used help as argument in their command because that would be pretty breaking for them.
Good point! i havent thought about this so far.. How could we best do this? |
@kitsunet Do you maybe have an idea, how we could solve this the best way? |
9ea016f
to
b1af6ca
Compare
I think @kitsunet is right and we can't provide safely this global flag without potentially breaking dedicated help arguments of the commands. |
if (is_array($commandLine) && in_array('--help', $commandLine, true)) { | ||
$request->setControllerCommandName('help'); | ||
$request->setArguments(['commandIdentifier' => $commandLine[0]]); | ||
$request->setControllerObjectName(HelpCommandController::class); | ||
return $request; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would put this logic at below line 155 of $commandIdentifier
so we can use this variable and also use $rawCommandLineArguments
meaning we support the $commandLine
being a string possibly.
Also the case flow --help
will with this implementation result in an error as there is no command id named --help
. The general help should be shown i suppose.
In the end this will make --help
an reserved argument and we have to agree on that (which is likely but still breaking? so !!!
?)
Also this raw lookup against --help
seems a little hacky. Like flow does support this short notation of boolean parameters but --help=true
or --help=false
are technically possible and will now still end up being passed to the final controller do we want that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would put this logic at below line 155 of $commandIdentifier so we can use this variable and also use $rawCommandLineArguments meaning we support the $commandLine being a string possibly.
So my check should also check if $rawCommandLineArguments
is a string? Dont fully understand what you mean.
Also the case flow --help will with this implementation result in an error as there is no command id named --help. The general help should be shown i suppose.
100%. Is there a way to trigger the default flow help
via PHP?
Thanks for this contribution. This is a feature that I'm missing forever. It's small, but it really enhances UX. If you're concerned about existing commands with a Lastly, I agree to @mhsdesign's comments about the check against |
Yes, that would be awesome. As i think this is really a good improvement. |
I wonder if there's actually any Flow application out there which implemented its own In that sense, what's missing to get this into 8.4? I'd love to have it in soon, so we can making plans for a release. |
Yeah sorry i didnt meant to side track it with asking what happens if
But by that i was just trying to make a point that some things are not thought out yet ^^
And the other points are still valid imo and have not been tackled. |
- allows `flow --help` - restricts that no command controller uses `$help` as custom option - remove duplicate set `HelpCommandController` - centralise $firstArgument "parsing" - respect that $commandLine could be a string Does not handle `flow cache:list --help=true` as this might be bungus
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
btw in b9fc7ea i also adjusted a few things earlier:
- allows
flow --help
- restricts that no command controller uses
$help
as custom option - remove duplicate set
HelpCommandController
- centralise $firstArgument "parsing"
- respect that $commandLine could be a string
Does not handle flow cache:list --help=true
as this might be bungus :D
... so definitely +1 and tested this ... and if youre all okay with my RuntimeException('The option --help is reserved ...')
then lets have it :)
Thanks u both! @mhsdesign @robertlemke ❤️ Sorry i havent continue working on that 😅 |
Upgrade instructions
None
Review instructions
This change introduces a new way of using the help function for existing Flow/Neos CLI commands.
Currently you always used:
./flow help user:create
With this change it is possible to use the new
--help
flag as an alternative at the end of a CLI command:But of course the first way will also still work!
Demo
336868613-915b3726-15bc-477a-aa53-d61682f04836.mov
Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions