Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[Console] Add completion to help & list commands#43596
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| thrownew \LogicException(sprintf('Command "%s" must implement "%s" to support completion.',\get_class($this->command), CompletionInput::class)); | ||
| } | ||
| $currentIndex =\count($input); |
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.
Shouldn't we make this a parameter (e.g. for cases where the suggestions for argument 1 is different based on argument 2?)
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.
Please open a PR. The index thing is tricky and I don't know to deal with it.
wouterj commentedOct 20, 2021
Thank you for starting this initiative@GromNaN ! |
fabpot commentedOct 20, 2021
Thank you@GromNaN. |
| publicfunctioncomplete(CompletionInput$input,CompletionSuggestions$suggestions):void | ||
| { | ||
| if ($input->mustSuggestArgumentValuesFor('namespace')) { |
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.
Would it be an improvement to create a "Helper", in order to have common functions forcomplete and calling it like this:
publicfunctionshouldSuggestValues(string$type):void {if ($input->mustSuggestArgumentValuesFor($type)) {$descriptor =newApplicationDescription($this->getApplication());$suggestions->suggestValues(array_keys($descriptor->getNamespaces()));return; }if ($input->mustSuggestOptionValuesFor('format')) {$helper =newDescriptorHelper();$suggestions->suggestValues($helper->getFormats()); }}
And calling it in thecomplete function forListCommand.php andHelpCommand.php?
// ListCommand.phppublicfunctioncomplete(CompletionInput$input,CompletionSuggestions$suggestions):void{$this->commandHelper->shouldSuggestValues('namespace');}
// HelpCommand.phppublicfunctioncomplete(CompletionInput$input,CompletionSuggestions$suggestions):void{$this->commandHelper->shouldSuggestValues('command_name');}
?
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.
Having a helper knowing about argument names of all Symfony commands does not make sense (and would require to make argument names unique across all commands)
BenjaminRbt commentedOct 20, 2021
| * | ||
| * @author Jérôme Tamarelle <jerome@tamarelle.net> | ||
| */ | ||
| class CommandCompletionTester |
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 make this one final
…, form, messenger, router (IonBazan)This PR was merged into the 5.4 branch.Discussion----------[Console] add suggestions for debug commands: firewall, form, messenger, router| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets |#43594| License | MIT| Doc PR | -Adding Bash completion for following commands:- `debug:firewall`- `debug:form`- `debug:messenger`- `debug:router`~Waiting for#43596 to be merged first as it adds testing utilities and `DescriptorHelper::getFormats()`.~Commits-------eaf9461 add suggestions for debug:firewall, debug:form, debug:messenger, debug:router
helpandlist--format, supported formats are exposed byDescriptorHelper