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

'invalid arguments' error when using globaloptions #51

Open
baldwint opened this issue Sep 8, 2012 · 5 comments
Open

'invalid arguments' error when using globaloptions #51

baldwint opened this issue Sep 8, 2012 · 5 comments

Comments

@baldwint
Copy link

baldwint commented Sep 8, 2012

I'm seeing a strange behavior when using globaloptions - specifying this keyword argument to dispatch seems to override the arguments introspected from the function.

This should reproduce it: https://gist.github.com/3672842

@piranha
Copy link
Owner

piranha commented Sep 10, 2012

Hm, interesting, thanks for report. I'll try to fix this ASAP.

@piranha
Copy link
Owner

piranha commented Sep 12, 2012

Hm, I can't reproduce it. Which version of opster do you use?

@piranha
Copy link
Owner

piranha commented Sep 12, 2012

Oh well, I'm sorry, I actually can. I'll consider that's a bug since I should improve error messaging somehow, but in short - add parameters to your commands so that they can receive those globaloptions. Even **kwargs will be enough.

@baldwint
Copy link
Author

Oh, I see.

Adding **kwargs to the argument list of every function is probably the only suitable way to fix this, actually. Manually adding parameters for each individual global option (e.g. username=None, password=None) will lead to an incorrect usage string. You'll get bug.py read PAGE [USERNAME] [PASSWORD], even though these can't be passed as positional arguments.

@piranha
Copy link
Owner

piranha commented Sep 17, 2012

Well, you can always pass your own usage string in @command(usage="PAGE").

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