argcomplete icon indicating copy to clipboard operation
argcomplete copied to clipboard

Some way to complete things with nargs > 1

Open asmeurer opened this issue 10 years ago • 2 comments

If you have nargs > 1 and you want to have different choices for each arg, you have to use a custom action (see http://stackoverflow.com/q/8624034/161801). It would be nice to have some way to still complete in that case, so that it doesn't complete the wrong thing for the wrong argument.

asmeurer avatar Jan 14 '14 17:01 asmeurer

What would you like to see argcomplete do?

It's definitely possible to do what you describe by defining a callable completer for your custom action and introspecting the arguments parsed so far (see the callable completer spec). Do you have something more intuitive in mind?

kislyuk avatar Jan 15 '14 03:01 kislyuk

I'll take a look at that. If I think of a more intuitive way to do it while implement it, I'll let you know.

I was hoping that defining __iter__ on an object passed to choices would be enough, but apparently argparse itself doesn't make this distinction (i.e., instead of iterating (choice1a, choice2a), (choice1b, choice2b), and so on, you have to iterate choice1a, choice2a, choice1b, choice2b, ....

asmeurer avatar Jan 17 '14 02:01 asmeurer