-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Accept argv list in calls to Fire #53
Comments
just a thought - I think it'd be more consistent to accept the equivalent of e.g. here's snippet from argparse.py:
https://svn.python.org/projects/python/trunk/Lib/argparse.py |
Yeah, that may make more sense. One option that preserves backwards compatibility is
I would rather "get it right" than preserve backwards compatibility since the project is young and these are undocumented and largely unused arguments. I'm tempted to (once completion is updated) remove the We should also try to get the argument names right: I think my preference is:
I think it's ok that this renames One concern here is that if we later remove the |
I agree that breaking backwards compatibility is the right choice here - especially if you can carry over knowledge from argparse to fire. My bikeshed:
I believe the reason you'd want to overwrite name is when aliasing commands (like |
I think I agree with both of you there. Make a clean interface, via |
For some context, right now we use And there are two times I can think of where you'd maybe (?) want to set
It's worth noting here that it's possible for a completion script to do alias resolution, though we don't do it yet. I also need to think more about what name + usage strings should look like if you call Fire from inside a function that was already called by Fire (as we will likely do in #29). |
Having thought more about this, I'm inclined to keep the "command" argument rather than replacing it with "args". We'll make it accept both a list of args or a string. It does after all represent the Fire command, and while args would also be a suitable (perhaps better!) name, I've come to think that the backwards compatibility argument outweighs this. [I don't want to come under fire for breaking the API!] [Relatedly, there is also precedent for accepting a command both as a string or a list of arguments (subprocess.py), though they use the name args.]
If you call Fire with:
The third case (command is supplied but name is not) is the most interesting one. I'm inclined to use sys.argv[0] in this case, but am also considering removing the name from the usage strings altogether in this case. When calling Fire from a method launched with Fire, one will either: We unofficially enable a) with the decorator in decorators.py |
Resolved with b5053ba. |
Currently Fire() uses sys.argv. It should also be able to accept an argv passed in directly to the call to Fire.
Some considerations:
command
which is a string. Do we still want to accept a string (if yes, do we continue using the namecommand
or do we just use the nameargv
?command
argument, we can use BigQuery to find all instances of people using this argument and send them a pull request fixing it. It's undocumented, so 1) I don't think we have any obligation to do this, and 2) there shouldn't be many people using this argument, so sending the pull requests shouldn't be too big a job.The text was updated successfully, but these errors were encountered: