mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1175968 - Honor '-h' or '--help' only if it appears before '--'; r=gps
--HG-- extra : commitid : DQ1fwp6yyLQ extra : amend_source : 9f556fa52c94be417d46ac57930520248b7b715d
This commit is contained in:
parent
00bfc9f9d8
commit
5b30ad463d
@ -92,7 +92,6 @@ class CommandAction(argparse.Action):
|
|||||||
elif values:
|
elif values:
|
||||||
command = values[0].lower()
|
command = values[0].lower()
|
||||||
args = values[1:]
|
args = values[1:]
|
||||||
|
|
||||||
if command == 'help':
|
if command == 'help':
|
||||||
if args and args[0] not in ['-h', '--help']:
|
if args and args[0] not in ['-h', '--help']:
|
||||||
# Make sure args[0] is indeed a command.
|
# Make sure args[0] is indeed a command.
|
||||||
@ -102,8 +101,17 @@ class CommandAction(argparse.Action):
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
elif '-h' in args or '--help' in args:
|
elif '-h' in args or '--help' in args:
|
||||||
# -h or --help is in the command arguments.
|
# -h or --help is in the command arguments.
|
||||||
self._handle_command_help(parser, command)
|
if '--' in args:
|
||||||
|
# -- is in command arguments
|
||||||
|
if '-h' in args[:args.index('--')] or '--help' in args[:args.index('--')]:
|
||||||
|
# Honor -h or --help only if it appears before --
|
||||||
|
self._handle_main_help(parser, command)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
self._handle_main_help(parser, command)
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise NoCommandError()
|
raise NoCommandError()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user