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

Use REMAINDER for --run-script to allow passing arbitrary arguments #45

Merged
merged 1 commit into from
Oct 19, 2018
Merged

Use REMAINDER for --run-script to allow passing arbitrary arguments #45

merged 1 commit into from
Oct 19, 2018

Conversation

jdufresne
Copy link
Contributor

Regression mistakenly introduced in f3dd542.

@pwaller
Copy link
Owner

pwaller commented Oct 10, 2018

Reading the argparse docs, I don't understand this one, can you explain it?

@jdufresne
Copy link
Contributor Author

Before this change, the following command:

$ pyprof2calltree --run-script myscript.py --kcachegrind

Would run myscript.py without any arguments and then pyprof2calltree would launch kcachegrind.

After this change it will run myscript.py with the argument --kcachegrind.

Using the REMAINDER argument means all remaining arguments after --run-script will be assigned to args.script.

Basically, in the example above, we can't assume that --kcachegrind is for pyprof2calltree and not for myscript.py. So, err on the side of the script. To run the example above with --kcachegrind as an argument to pyprof2calltree, one would need to pass it before --run-script. e.g.:

$ pyprof2calltree --kcachegrind --run-script myscript.py

From the Python docs:

All the remaining command-line arguments are gathered into a list. This is commonly useful for command line utilities that dispatch to other command line utilities

This describes pyprof2calltree's use case exactly.

Does that make sense? I can try to provide additional details if you think it will help.

@pwaller pwaller merged commit f1b86f7 into pwaller:master Oct 19, 2018
@jdufresne jdufresne deleted the remainder branch April 19, 2020 14:53
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

Successfully merging this pull request may close these issues.

2 participants