From: Frantisek Tobias Date: Fri, 15 Nov 2024 12:12:33 +0000 (+0100) Subject: kresctl: command: completion: remove redundant code X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fenvironments%2Fdocs-develop-kres-ph09xl%2Fdeployments%2F5649;p=thirdparty%2Fknot-resolver.git kresctl: command: completion: remove redundant code --- diff --git a/python/knot_resolver/client/command.py b/python/knot_resolver/client/command.py index dbd99227a..33f2c2ad9 100644 --- a/python/knot_resolver/client/command.py +++ b/python/knot_resolver/client/command.py @@ -152,20 +152,12 @@ class Command(ABC): curr_index += 1 if subpar: cmd = get_subparser_command(subpar) - if cmd is not None: - if len(args) > curr_index: - words = cmd.completion(subpar, args, curr_index) + if cmd is None: + return get_subparsers_words(subpar._actions) # pylint: disable=protected-access - return words + if len(args) > curr_index: + return cmd.completion(subpar, args, curr_index) - subpar_actions = subpar._actions # pylint: disable=protected-access - subparser_words = get_subparsers_words(subpar_actions) - words = {} - for action in subpar_actions: - if action.dest not in subparser_words: - subparser_words[action.dest] = action.help or None - - words.update(subparser_words) return words elif uarg in ["-s", "--socket", "-c", "--config"]: