These are chat archives for kbknapp/clap-rs

Jun 2018
So for example, running $ rustup completions bash prints the completion script for Bash.
Now if you're wanting to add $ foo <tab><tab> automatically looks for all "plugins" and lists them as subcommand options for foo that's a bit more complicated and not supported directly in clap yet. It requires running arbitrary code for each completion and is covered in the issue #568 and #1232
Kevin K.
Jun 12 2018 00:07
However, if you wanted foo to have the ability to generate a completion script for itself, including all plugins and for said plugins to also be able to generate a completion script for themselves which you just merge with foo that is possible and along the lines of the rustup suggestion.
The way that would work is to have a argument or subcommand which does all the generation (like rustup), for example $ foo generate which would then search for all plugins, and add their name as "subcommands" to the main foo binary. It would gen generate a script like normal, then it would call each of the plugins with their "hidden" argument to have them generate their completion scripts. It would then insert/merge those scripts into the foo completion script at the appropriate places (which is different for each shell).
Hopefully that helps :)
Vasyl Purchel
Jun 12 2018 07:39
yup, I was thinking on a same solution thanks :)