From b01cfc77cf2bce0deaf167ded62f7f2d647b1422 Mon Sep 17 00:00:00 2001 From: dgelessus Date: Tue, 7 Jul 2020 00:01:57 +0200 Subject: [PATCH] Don't pass required=True to add_subparsers The required kwarg of add_subparsers was only added in Python 3.7, and we currently still support Python 3.6. --- rsrcfork/__main__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rsrcfork/__main__.py b/rsrcfork/__main__.py index 1efe412..5545c07 100644 --- a/rsrcfork/__main__.py +++ b/rsrcfork/__main__.py @@ -671,7 +671,7 @@ rsrcfork library, which this tool is a part of. subs = ap.add_subparsers( dest="subcommand", - required=True, + # TODO Add required=True (added in Python 3.7) once we drop Python 3.6 compatibility. metavar="SUBCOMMAND", ) @@ -804,7 +804,11 @@ handle resource compression). ns = ap.parse_args() - if ns.subcommand == "read-header": + if ns.subcommand is None: + # TODO Remove this branch once we drop Python 3.6 compatibility, because this case will be handled by passing required=True to add_subparsers (see above). + print("Missing subcommand", file=sys.stderr) + sys.exit(2) + elif ns.subcommand == "read-header": do_read_header(ns) elif ns.subcommand == "info": do_info(ns)