This would have been a very nice addition. Although this cannot be currently implemented due to Clap
not having an implementation of generating completions from structs. Though this is possible with the builder pattern
To be honest I don’t understand how clap would help here. At the time I want to see the completion, I’m still entering a line in the CLI, so the program hasn’t started yet.
A clap app has the function generate_completions
to output auto completions for a specific shell into a file. This file is loaded by the shell to provide the completions. The problem with our implementation using structs is that it does not have such a method
No, I get that, but I don’t see how clap
can generate completions for runtime information like what channels the current repo has.
see
Wow, TIL. Thanks for the links!
Clap maintainer here, what’s the issue with generating completions from structs? Opts::into_app()
should give you the built clap::App
Oh Thank you very much. I didn’t knew about the into_app()
method
So, what’s the way to go forward here? I would be willing to help with zsh completions.
In
git
, if you type e.g.git switch
and hitTab
, you will get a list of all your branches. I don’t know how this kind of completion works, but it would be very nice to have.