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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 12 additions & 3 deletions IPython/config/application.py
Expand Up @@ -419,13 +419,22 @@ def parse_command_line(self, argv=None):
# it's a subcommand, and *not* a flag or class parameter
return self.initialize_subcommand(subc, subargv)

if '-h' in argv or '--help' in argv or '--help-all' in argv:
# Arguments after a '--' argument are for the script IPython may be
# about to run, not IPython iteslf. For arguments parsed here (help and
# version), we want to only search the arguments up to the first
# occurrence of '--', which we're calling interpreted_argv.
try:
interpreted_argv = argv[:argv.index('--')]
except ValueError:
interpreted_argv = argv

if any(x in interpreted_argv for x in ('-h', '--help-all', '--help')):
self.print_description()
self.print_help('--help-all' in argv)
self.print_help('--help-all' in interpreted_argv)
self.print_examples()
self.exit(0)

if '--version' in argv or '-V' in argv:
if '--version' in interpreted_argv or '-V' in interpreted_argv:
self.print_version()
self.exit(0)

Expand Down