Open grondo opened 1 year ago
There are a couple, one of the best known is probably https://kislyuk.github.io/argcomplete/, though I am not sure that has a convenient way to export the completions, it can do completion for essentially any argparse-based program. This one is newer (I think) and I haven't actually used it, but I've heard great things and it can actually generate scripts we can install rather than doing it dynamically: https://github.com/iterative/shtab
I actually think a decent way to do this might be to write a little python wrapper that can load all the optparse definitions from a C library and just run them through shtab. That way we only have to learn one generator and write one conversion of a format we know well rather than having to come up with something new from whole cloth.
Great idea!
It would be nice if liboptparse had an introspection or completion helper option that let a caller query the subcommands and options available in a Flux command using optparse. Not only would this allow completions to be easily kept up-to-date, but would also be helpful in making a suggestion system for flux, e.g. if a user types
flux kill JOBID
, they might getkill is not a flux command. Try flux job kill
or similar.@trws mentioned an existing solution for argparse. We could make a compatible solution for optparse.