Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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