From b4db42dd3dcb2e59c78b1d432818f9fc35363be3 Mon Sep 17 00:00:00 2001 From: Leandro Nunes Date: Tue, 6 Oct 2020 13:47:24 +0100 Subject: [PATCH] [TVMC] fail gracefully in case no subcommand is provided (#6625) --- python/tvm/driver/tvmc/main.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/python/tvm/driver/tvmc/main.py b/python/tvm/driver/tvmc/main.py index 937134103ad3..fee04db820fb 100644 --- a/python/tvm/driver/tvmc/main.py +++ b/python/tvm/driver/tvmc/main.py @@ -79,7 +79,10 @@ def _main(argv): sys.stdout.write("%s\n" % version) return 0 - assert hasattr(args, "func"), "Error: missing 'func' attribute for subcommand {0}".format(argv) + if not hasattr(args, "func"): + # In case no valid subcommand is provided, show usage and exit + parser.print_help(sys.stderr) + return 1 try: return args.func(args)