topgrade icon indicating copy to clipboard operation
topgrade copied to clipboard

Topgrade should support tab-completions

Open PolpOnline opened this issue 2 years ago • 3 comments

This could be implemented using a library like clap to parse command-line arguments and automatically compile shell completions for a number of different shells. I believe the best option is to let the user generate the completions and put them into the right directory (like GitHub-CLI does). If someone implements this feature I can test it on my Arch machine.

PolpOnline avatar Dec 24 '21 14:12 PolpOnline

I've done a little research into how to go about this with structopt, it looks like we just need to call:

CommandLineArgs::clap().gen_completions_to(...)

It takes the name of the program, the shell to generate completions for, and the buffer to write them to, as arguments. If we're going to leave it up to the user to install them (which I agree is preferable to trying to detect where to install them), we can just write to standard output. It would also be nice if we could include them in package manager releases, the same function can be called within build.rs.

mtoohey31 avatar Feb 06 '22 19:02 mtoohey31

@mtoohey31 I don't see this function in clap v3. Do you know if they removed it?

r-darwish avatar May 04 '22 13:05 r-darwish

They pulled it into a companion crate, clap_complete.

MCOfficer avatar May 04 '22 14:05 MCOfficer