Skip to content

Commit

Permalink
kresctl: command: completion: remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
Frantisek Tobias committed Nov 15, 2024
1 parent d54a420 commit 0a6d807
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions python/knot_resolver/client/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,12 @@ def completion(parser: argparse.ArgumentParser, args: Optional[List[str]] = None
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"]:
Expand Down

0 comments on commit 0a6d807

Please sign in to comment.