-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Better handling of argument name typos #84
Comments
Thanks for this suggestion! It's a good idea, and I will let you know if we decide to go with this design change in a future version. |
@gerardlouw, would you be interested in making this improvement? |
Sure, I'd be happy to send a pull request. Could you point me to where in the code this should go? From a quick glance, it looks like Lines 663 to 741 in e76a10c
|
The call paths we're interested in are: (_Fire -> _CallCallable -> _MakeParseFn) and (_Fire -> _CallCallable -> parse -> _ParseArgs). The Lines 566 to 567 in e76a10c
In particular we're interested in the Lines 638 to 644 in e76a10c
Line 644 is where we indiscriminately take one of the remaining args and treat it as a positional arg. |
Just for clarification, will we consider these variables for varargs? |
What do you think about the following? If:
Then:
|
Thanks! Can I remove these arguments in '_ParseKeywordArgs' to avoid being assigned to varargs? |
Ack! I only just noticed your question now. Sorry for the delay. Yes, handling these arguments in _ParseKeywordArgs sounds reasonable to me. Edit: Oh, and I see you've already done something very similar to this. I'll take a look at it now. |
Thanks for the contribution! |
Thanks for your help! |
Using this minimal example of a Python-fire CLI:
This is the result I get:
As you can see, a typo in the argument leads to unexpected behaviour, which can be really hard to debug.
I would suggest never treating an argument matching
--[a-zA-Z0-9_-]+
as positional, without some sort of escaping by the user (perhaps similar to the escaping you require to avoid parsing ints, etc.).The text was updated successfully, but these errors were encountered: