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

Fix issue #2660: parsing of help and version arguments #2663

Merged
merged 1 commit into from Dec 7, 2012

Conversation

timodonnell
Copy link

Help (-h --help --help-all) and version (--version -V) arguments that appear after a bare '--' argument are passed to the script IPython is running (like other arguments), instead of causing IPython itself to
write out help / version info.

…rsion -V)

arguments that appear after a bare '--' argument are passed to the script
IPython is running (like other arguments), instead of causing IPython itself to
write out help / version info.
@bfroehle
Copy link
Contributor

bfroehle commented Dec 7, 2012

Looks fine to me.

@takluyver
Copy link
Member

The only thing I wonder is if we should be even more cautious about finding these arguments. i.e. if you run ipython foo.py -h, I think most people would expect foo.py to be run, rather than displaying IPython's help and exiting.

The Python interpreter only looks at the options before the first 'interface option' - which means a filename, -c or -m. See http://docs.python.org/3/using/cmdline.html

@bfroehle
Copy link
Contributor

bfroehle commented Dec 7, 2012

@takluyver I've looked into this in the past and found that it is quite difficult (i.e., impossible?) to wrangle argparse into this same sort of behavior. There isn't any way to specify that some argument is "final" in the parsing. I'd rather not invest time into writing an argument parser by hand, especially for our complex use case.

I think we should accept this as a workable compromise and move on (for now).

@takluyver
Copy link
Member

But this section of the code isn't even doing anything with argparse - it's
just looking for specific arguments in a list. But anyway, I'm happy to
accept this as is.

On 7 December 2012 18:11, Bradley M. Froehle notifications@github.comwrote:

@takluyver https://github.com/takluyver I've looked into this in the
past and found that it is quite difficult (i.e., impossible?) to wrangle
argparse into this same sort of behavior. There isn't any way to specify
that some argument is "final" in the parsing. I'd rather not invest time
into writing an argument parser by hand, especially for our complex use
case.

I think we should accept this as a workable compromise and move on (for
now).


Reply to this email directly or view it on GitHubhttps://github.com//pull/2663#issuecomment-11140183.

@bfroehle
Copy link
Contributor

bfroehle commented Dec 7, 2012

You are right... something like interpreted_argv = argv[:argv.first_index_of('--', '-c', '-m')] would be best. But it's hard to check for the most common case --- a filename.

In addition, since this will get parsed with argparse next the user is probably going to have to use -- to separate IPython arguments from script arguments anyway, so there is little point in doing a more sophisticated check here.

(Or am I wrong about that.. do we check explicitly for -c and -m elsewhere?)

bfroehle added a commit that referenced this pull request Dec 7, 2012
Fix issue #2660: parsing of help and version arguments
@bfroehle bfroehle merged commit 591e9b3 into ipython:master Dec 7, 2012
minrk added a commit that referenced this pull request Mar 5, 2013
…ents

Help (-h --help --help-all) and version (--version -V) arguments that appear after a bare '--' argument are passed to the script IPython is running (like other arguments), instead of causing IPython itself to
write out help / version info.
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
…2660

Fix issue ipython#2660: parsing of help and version arguments
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.

None yet

3 participants