use argparse's built-in mutually exclusive groups

This commit is contained in:
Connor Olding 2020-09-08 13:09:29 +02:00
parent e1ff8918cc
commit 41e489671f

View file

@ -19,11 +19,13 @@ def ui(program, args):
desc = "enable pretty-printing progress to stderr"
parser.add_argument("--progress", action="store_true", help=desc)
chkgrp = parser.add_mutually_exclusive_group()
desc = "enable all checks instead of only the most likely ones"
parser.add_argument("--all", action="store_true", help=desc)
chkgrp.add_argument("--all", action="store_true", help=desc)
desc = "enable only the first check"
parser.add_argument("--first", action="store_true", help=desc)
chkgrp.add_argument("--first", action="store_true", help=desc)
desc = "enable debugging verbosity"
parser.add_argument("--debug", action="store_true", help=desc)
@ -31,9 +33,7 @@ def ui(program, args):
a = parser.parse_args(args)
checks = [] + chk.first
if a.first and a.all:
parser.error("--all and --first cannot be used together")
elif a.all:
if a.all:
checks += chk.checks
elif a.first:
pass