Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
Zsh shell autocompletions#43970
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
adhocore commentedNov 9, 2021
maybe a false positive in fabbot ci for typo? the |
stof commentedNov 9, 2021
Yeah, this definitely looks like a false positive |
adhocore commentedNov 9, 2021
@stof i used auto sync upstream from github ui, so any idea how can i remove the Merge commit now? |
GromNaN left a comment
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 that you added comments in the script; especially since we don't have a way to write test on it for now.
I have a suggestion to avoid shell-specific code inApplication class.
| $suggestions->suggestValues(array_filter(array_map(function (Command$command) { | ||
| return$command->isHidden() ?null :$command->getName(); | ||
| $suggestions->suggestValues(array_filter(array_map(function (Command$command)use ($input){ | ||
| return$command->isHidden() ?null :$command->getName().($input->isShell('zsh') ?"\t".$command->getDescription() :''); |
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.
Testing if shell is zsh seems very specific for this place.
We could use a DTO. TheZshCompletionOutput would format the value with its specificities. By implementing the__toString method, theBashCompletionOutput would not require any change.
namespaceSymfony\Component\Console\Completion;finalclass SuggestedValue {private$value;private$description;publicfunction__construct(string$value,string$description =null) {$this->value =$value;$this->description =$description; }publicfunction__toString():string {return$this->value; }}
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.
or maybe some abstraction to tell/handle if the shell supports description for autocompleted suggestion
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.
That would add complexity in all commands that implements completion. I'm not sure this is something we want.
Each command should set suggestions values, optionally with a description using this DTO.
| # Ensure atleast 1 input | ||
| if ["${i}"="" ];then | ||
| requestComp="${requestComp} -i\"\"" |
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.
That makes theCompletionInput::getCurrentValue() equals to a space? it would be better to skip the value entirely.
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 think it still requires -i option equal or 1 more than -c option that's why
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.
Then, does it work with an empty string?
| requestComp="${requestComp} -i\"\"" | |
| requestComp="${requestComp} -i\"\" |
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.
no it can't be empty
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Jérôme Tamarelle <jerome@tamarelle.net>
fabpot commentedJul 20, 2022
GromNaN commentedJul 21, 2022 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
This PR was merged into the 6.2 branch.Discussion----------[Console] Zsh shell autocompletion| Q | A| ------------- | ---| Branch? | 6.2| Bug fix? | no| New feature? | yes| Deprecations? | no| Tickets |Fix#43592| License | MIT| Doc PR | todoContinuation of#43970* Rebased, including bug fixes.* Added description to completion values, implemented for commands and options names. (should be used for fish also)```% bin/console [TAB]about -- Display information about the current projectassets:install -- Install bundle's web assets under a public directorycache:clear -- Clear the cachecache:pool:clear -- Clear cache pools```Commits-------3c2e1a4 Finish Zsh completion405f207 Add zsh completion
Uh oh!
There was an error while loading.Please reload this page.
Usage
Setup/Install
In
zshterminal run:which will add dumped zsh completion helper in first fpath (zsh's functions autoload path).
Then reload shell or just do
source "$fpath[1]/console".Here's a simple script
sfzshthat I'm using while adding thezsh autocompletion support as a testbed:Toggle code
Autocomplete commands
Autocomplete options
Autocomplete option values
Autocomplete args