-
Notifications
You must be signed in to change notification settings - Fork 249
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
Shell completions #1856
base: main
Are you sure you want to change the base?
Shell completions #1856
Conversation
Signed-off-by: itowlson <[email protected]>
I haven't found any documents indicating that zsh or fish completions can be written in anything other than |
zsh does have bash completion compat via |
Works in Bash, although it seems en expensive route without zsh and Fish support. Seems like this is harder than expected. |
This is back on the want list for Spin 2.1. What's the best way to figure out a path to delivery? cc @mikkelhegn @melissaklein24 |
My observation, based on the information in this PR is that what's left is a decision about how to implement it. I have no qualified opinion on that. Prioritizing requirements, I think the shells we should support (in priority), would be zsh, bash and fish. |
If zsh is highest priority, then the approach here won't work. That puts us back to If we do that, I might maybe see if I can ship the "better" bash completions as a Spin plugin, for those as want them. |
Sounds like a plan, maybe getting the first version out there inspires improvements to either of the approaches. |
This is a second crack at command completions. It doesn't use the
clap_complete
module because that didn't do a great job; instead, it uses custom code which, well, I don't know if it does a great job either, but it is a bit smarter at least. For example:spin up
and friends get completions for their forwarded arguments (e.g. trigger args)spin new
andspin add
are completed with a list of installed templatesspin plugin
commands are completed with lists of installed or known plugins as appropriateThe way this works is:
_spin_completions
complete -C </path/to/_spin_completions> spin
to install the completionsObviously we would want to put a bit more user experience around that!
Known issues:
spin up
and related stuff. [Fixable.]Completioninput
trait for other shells but not sure if we have the knowledge or time.)Could we use
clap_complete
and amend it by hand?We could.
clap complete
spits out a big ball o' shell script - we could capture that and fix it up manually. This would likely mean we had to manually maintain the completions in shell - it would be hard to capture the changes in a way that we could re-apply after a Spin CLI change. But it would take someone shellier than me - I had a crack at the bash one with no joy. I think it would take a substantial refactor, but after that maybe it would be okay?Could we implement the
CompletionInput
trait for zsh and fish, and get them that way?I don't know how hard it would be. It's a bit of a diversion and (the upstream
shell_completion
repo is pretty idle.)[https://github.com/joshmcguigan/shell_completion] so I dunno if they would find a home upstream. In principle the core engine should work fine with other shells though.Anyway here we are and I throw myself on the mercy of the court