-
Notifications
You must be signed in to change notification settings - Fork 257
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
Add shell completions #1032
base: main
Are you sure you want to change the base?
Add shell completions #1032
Conversation
@itowlson I wasn't able to get the flow working on my end. I did the following:
Am i missing a step? |
@kate-goldenring It looks like it only works if |
I dunno if this is a bash limitation or if there is an incantation we can do to make it behave properly. |
Kate reports that it now blows up on |
All right, it looks like on
Thanks @kate-goldenring for working through this! |
I wanted to tru this in my Fish shell, but got stuck here:
I've built the debug version from this PR branch. |
As a totally unrelated side-note, I just realized the word play of having a Fish shell!!! Have only been using thing thing for at least two years now... |
@mikkelhegn I believe it has been renamed to remove |
@mikkelhegn I updated the description without leaving a comment; my bad. I changed the syntax to |
Paging @bacongobbler and @adamreese, who might have more background on building completions for CLIs. |
Thanks for getting this started. We should exclude hidden commands like Adding completers for commands like |
@itowlson - Is this something we could consider for 2.0? |
@mikkelhegn The question, for me, is: given what we now know about the limitations of doing it the quick way, and the cost of doing it a nicer way, how do we want to proceed:
We can then define what we want the user experience to be (e.g. the This is independent of 2.0 (at least at the technical level) - nothing in this would involve breaking changes as far as I know. |
My preference, stack ranked would be: 3, 2, 1 :-) I'll leave it to the overall prioritization for the team to decide if this is above the cut line. I think we should have some completion in 2.0 (as the project now starts to really mature). Will either of the above also work for plug-ins out-of-the-box? |
The quick way won't for plugins, though with the Clap shenanigans in #1560 it might list initial plugin names - but it is purely static, derived from the Clap command structures. The nice way... who knows? I wouldn't be optimistic, and at minimum it would depend on the plugin providing a way to |
Signed-off-by: itowlson <[email protected]>
Signed-off-by: itowlson <[email protected]>
Another effort related to this: https://github.com/karthik2804/spin-autocomplete @karthik2804 @itowlson |
I had a quick play with this to see what it could give us and there is good news and there is bad news.
The good news is that we can get completions for things like commands and options. E.g.
spin de<TAB>
->spin deploy
,spin new --va<TAB>
->--value --values-file
.The bad news is that nothing else really works - at least on bash. (Maybe it would have worked better on zsh.) All value completions seem to be "any path."
clap_complete
supports a bunch of value hints but ignores all of them, or at least all the ones I tried. For example,ValueHint::FilePath
,ValueHint::DirPath
andValueHint::Url
all resolve tocompgen -f
which is files and directories. I don't know if this is fixed in more recent versions ofclap_complete
, but I did find an issue where people were asking for dynamic completions (e.g.spin template new <TAB>
and it would give you a list of templates) and it wasn't happening.In this draft, the user experience is bad news too. You would run
spin generate-completions {bash|zsh|...} >spincomps
, thenchmod +x spincomps
, then addsource spincomps
to your.bashrc
or user completions file or something like that. Then you upgrade Spin and do the dance again. If we think command and option completion is worth it, we can discuss a better UI, and whether to support other shells.And right now the code is also bad news, but I wanted to get opinions on whether we wanted this and if so what we wanted it to look like before I invested in niceing it up.
Signed-off-by: itowlson [email protected]