spin icon indicating copy to clipboard operation
spin copied to clipboard

Add shell completions

Open itowlson opened this issue 1 year ago • 17 comments

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 and ValueHint::Url all resolve to compgen -f which is files and directories. I don't know if this is fixed in more recent versions of clap_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, then chmod +x spincomps, then add source 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]

itowlson avatar Jan 17 '23 23:01 itowlson