From ac01eb47dcc68f42bd93c382076702e9de8690b4 Mon Sep 17 00:00:00 2001 From: Leonardo Sandoval Date: Mon, 18 Jun 2018 10:22:53 -0500 Subject: [PATCH] bmaptools/CLI.py: Print help in case of no arguments This fix avoids the following run-time exception: $ bmaptool Traceback (most recent call last): File "/usr/bin/bmaptool", line 11, in load_entry_point('bmap-tools==3.4', 'console_scripts', 'bmaptool')() File "/usr/lib/python3.6/site-packages/bmaptools/CLI.py", line 715, in main args.func(args) AttributeError: 'Namespace' object has no attribute 'func' --- bmaptools/CLI.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bmaptools/CLI.py b/bmaptools/CLI.py index 1dae44a..123ccba 100644 --- a/bmaptools/CLI.py +++ b/bmaptools/CLI.py @@ -641,7 +641,7 @@ def parse_arguments(): text = "do not verify the data checksum while writing" parser_copy.add_argument("--no-verify", action="store_true", help=text) - return parser.parse_args() + return (parser, parser.parse_args()) def setup_logger(loglevel): @@ -701,7 +701,7 @@ def format(self, record): def main(): """Script entry point.""" - args = parse_arguments() + parser, args = parse_arguments() if args.quiet: loglevel = logging.WARNING @@ -716,7 +716,10 @@ def main(): error_out("--quiet and --debug cannot be used together") try: - args.func(args) + if hasattr(args, 'func'): + args.func(args) + else: + parser.print_help() except MemoryError: log.error("Out of memory!") traceback.print_exc()