do not exit with an error when $command --help is successfully used

When checking for a minimum requirement of arguments and aborting with
the help text otherwise, we should first check to see if the help text
was explicitly asked for.
This commit is contained in:
Eli Schwartz 2019-04-09 15:21:23 -04:00
parent 2edc343f77
commit 378c78429e
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
2 changed files with 7 additions and 1 deletions

View File

@ -238,6 +238,9 @@ def main(args=sys.argv):
if len(args) < 2:
parser.print_help()
return 1
if args[1] in ('-h', '--help'):
parser.print_help()
return 0
if args[1] == '--version':
parser.print_version()
return 0

View File

@ -308,7 +308,10 @@ def create_option_parser(args, log):
parser = option_parser()
if len(args) < 3:
print_help(parser, log)
raise SystemExit(1)
if any(x in args for x in ('-h', '--help')):
raise SystemExit(0)
else:
raise SystemExit(1)
input, output = check_command_line_options(parser, args, log)