From 2819d42c6f6277db3056596b6a8767e2dfaae391 Mon Sep 17 00:00:00 2001 From: Mats Kindahl Date: Fri, 8 Dec 2023 10:59:23 +0100 Subject: [PATCH] fix: call without --list failed If doctor was called without `--list` it would print an error that `--show` was given but not `--list`. This commit fixes that by setting `--show` to `None` by default and then setting the default value if it was not set. --- src/doctor/cli.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/doctor/cli.py b/src/doctor/cli.py index 09e27e8..2ddf500 100644 --- a/src/doctor/cli.py +++ b/src/doctor/cli.py @@ -47,7 +47,7 @@ def parse_arguments(): help=("List rules matching pattern. " "If no pattern is given, will list all rules")) parser.add_argument( - '--show', choices=['brief', 'message', 'details'], default="brief", + '--show', choices=['brief', 'message', 'details'], default=None, help=("What to show from the rule. The brief description is always shown, " "but it is possible to show the message and the detailed message as " "well.") @@ -61,6 +61,8 @@ def main(): if args.show and 'list' not in args: parser.error("called with '--show' but without '--list'") elif 'list' in args: + if args.show is None: + args.show = 'brief' list_rules(args.list, args.show) else: check_rules(user=args.user, dbname=args.dbname, port=args.port, host=args.host)