From f413bf82f03a5dbf1aa0bee3f0d54f7a5ceadf3d Mon Sep 17 00:00:00 2001 From: thechief389 Date: Thu, 23 Aug 2018 02:34:27 -0400 Subject: [PATCH] Fix error when no arguments are specified (#240) Also, introduce a metavar for the command subparser, since it's currently a bit verbose. --- pokedex/main.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pokedex/main.py b/pokedex/main.py index ac83695..6044d9e 100644 --- a/pokedex/main.py +++ b/pokedex/main.py @@ -14,11 +14,12 @@ from pokedex import defaults def main(junk, *argv): - if len(argv) <= 0: - command_help() - return - parser = create_parser() + + if len(argv) <= 0: + parser.print_help() + sys.exit() + args = parser.parse_args(argv) args.func(parser, args) @@ -62,7 +63,7 @@ def create_parser(): parents=[common_parser], ) - cmds = parser.add_subparsers(title='Commands') + cmds = parser.add_subparsers(title='commands', metavar='', help='commands') cmd_help = cmds.add_parser( 'help', help=u'Display this message', parents=[common_parser])