[Feature Request] shell completions enhanced
clap support completion, so the cost of adding this feature is very low.
generating at compile-time or generating at runtime, please see: https://docs.rs/clap_complete/latest/clap_complete/
Consider supporting the following shells:
- nushell
- powershell
- zsh
- bash
- and more ...
Some links that may be useful: https://docs.rs/clap_complete_nushell/latest/clap_complete_nushell/
I've finished with clap_complete::generate_to aa2a84cf6339b8a0ab62e916232a1632bdf136b5 in build.rs.
However, the implementation is a little tedious and not easy using. I'll work on searching some more productive methods (maybe learn from git or kubectl).
As so far:
unstable-dynamicfeature ofclap_complete(poor document however)
Edit: Finally, I'd like to follow this example. However, only fish and zsh supported, I'll upload some other auto complete script for bash powershell and so on.
Thanks, it does work.
But it can be better (maybe not the goal), such as:
fav track
When i press tab, will display the results from fav status -l, only just press enter:
fav track bvid
or
fav track listid
Just like what happens when git switch.
So I think we can keep this issue open. Maybe you can add an enhanced tag to this issue.
PS: By the way, fav will regard the av number or cid (the id of one of the p in the video) as the bid, then the error will occur.
Maybe I should open a new issue to talk about this problem?
This may be called dynamic completion. I feel it's hard to work on. https://github.com/clap-rs/clap/issues/1232
Moreover, I am not very proficient in using the clap_complete crate, its design is so strange and hard to understand with poor documentation, and I don't quite understand how various terminals implement auto-completion. I have not yet completed it, so it's not usable, it cannot do normal easy completion on Windows powershell although works well with fish.
I'll reopen this issue and keep on finding better solution.