Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some way to complete things with nargs > 1 #73

Open
asmeurer opened this issue Jan 14, 2014 · 2 comments
Open

Some way to complete things with nargs > 1 #73

asmeurer opened this issue Jan 14, 2014 · 2 comments

Comments

@asmeurer
Copy link
Contributor

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.

@kislyuk
Copy link
Owner

kislyuk commented Jan 15, 2014

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?

@asmeurer
Copy link
Contributor Author

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, ....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants