From 37330d7288126b917d2e3ccab70400705f99c05d Mon Sep 17 00:00:00 2001 From: Frantisek Tobias Date: Fri, 11 Oct 2024 10:36:47 +0200 Subject: kresctl: tab-completion: auto-complete for all commands except config --- python/knot_resolver/client/commands/convert.py | 4 ++-- python/knot_resolver/client/commands/metrics.py | 4 ++-- python/knot_resolver/client/commands/schema.py | 5 ++--- python/knot_resolver/client/commands/validate.py | 4 ++-- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/python/knot_resolver/client/commands/convert.py b/python/knot_resolver/client/commands/convert.py index 412ed334..b72af758 100644 --- a/python/knot_resolver/client/commands/convert.py +++ b/python/knot_resolver/client/commands/convert.py @@ -3,7 +3,7 @@ import sys from pathlib import Path from typing import List, Optional, Tuple, Type -from knot_resolver.client.command import Command, CommandArgs, CompWords, register_command +from knot_resolver.client.command import Command, CommandArgs, CompWords, get_subparsers_words, register_command from knot_resolver.datamodel import KresConfig from knot_resolver.datamodel.globals import Context, reset_global_validation_context, set_global_validation_context from knot_resolver.utils.modeling import try_to_parse @@ -52,7 +52,7 @@ class ConvertCommand(Command): @staticmethod def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords: - return {} + return get_subparsers_words(parser._actions) # noqa: SLF001 def run(self, args: CommandArgs) -> None: with open(self.input_file, "r") as f: diff --git a/python/knot_resolver/client/commands/metrics.py b/python/knot_resolver/client/commands/metrics.py index 058cad8b..85cff258 100644 --- a/python/knot_resolver/client/commands/metrics.py +++ b/python/knot_resolver/client/commands/metrics.py @@ -2,7 +2,7 @@ import argparse import sys from typing import List, Optional, Tuple, Type -from knot_resolver.client.command import Command, CommandArgs, CompWords, register_command +from knot_resolver.client.command import Command, CommandArgs, CompWords, get_subparsers_words, register_command from knot_resolver.utils.modeling.parsing import DataFormat, parse_json from knot_resolver.utils.requests import request @@ -44,7 +44,7 @@ class MetricsCommand(Command): @staticmethod def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords: - return {} + return get_subparsers_words(parser._actions) # noqa: SLF001 def run(self, args: CommandArgs) -> None: response = request(args.socket, "GET", "metrics/prometheus" if self.prometheus else "metrics/json") diff --git a/python/knot_resolver/client/commands/schema.py b/python/knot_resolver/client/commands/schema.py index 0c63f398..fa7465c1 100644 --- a/python/knot_resolver/client/commands/schema.py +++ b/python/knot_resolver/client/commands/schema.py @@ -3,7 +3,7 @@ import json import sys from typing import List, Optional, Tuple, Type -from knot_resolver.client.command import Command, CommandArgs, CompWords, register_command +from knot_resolver.client.command import Command, CommandArgs, CompWords, get_subparsers_words, register_command from knot_resolver.datamodel import kres_config_json_schema from knot_resolver.utils.requests import request @@ -35,8 +35,7 @@ class SchemaCommand(Command): @staticmethod def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords: - return {} - # return parser_words(parser._actions) # pylint: disable=W0212 + return get_subparsers_words(parser._actions) # noqa: SLF001 def run(self, args: CommandArgs) -> None: if self.live: diff --git a/python/knot_resolver/client/commands/validate.py b/python/knot_resolver/client/commands/validate.py index f7477748..141a2003 100644 --- a/python/knot_resolver/client/commands/validate.py +++ b/python/knot_resolver/client/commands/validate.py @@ -3,7 +3,7 @@ import sys from pathlib import Path from typing import List, Tuple, Type -from knot_resolver.client.command import Command, CommandArgs, CompWords, register_command +from knot_resolver.client.command import Command, CommandArgs, CompWords, get_subparsers_words, register_command from knot_resolver.datamodel import KresConfig from knot_resolver.datamodel.globals import Context, reset_global_validation_context, set_global_validation_context from knot_resolver.utils.modeling import try_to_parse @@ -41,7 +41,7 @@ class ValidateCommand(Command): @staticmethod def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords: - return {} + return get_subparsers_words(parser._actions) # noqa: SLF001 def run(self, args: CommandArgs) -> None: if self.input_file: -- cgit v1.2.3