From 41e489671f0ae00f57b3a98f70776b8447607a76 Mon Sep 17 00:00:00 2001 From: Connor Olding Date: Tue, 8 Sep 2020 13:09:29 +0200 Subject: [PATCH] use argparse's built-in mutually exclusive groups --- respodns/ui.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/respodns/ui.py b/respodns/ui.py index 4398321..206a27a 100644 --- a/respodns/ui.py +++ b/respodns/ui.py @@ -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