summaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorFrantisek Tobias <frantisek.tobias@nic.cz>2024-10-11 10:36:47 +0200
committerAleš Mrázek <ales.mrazek@nic.cz>2024-12-20 22:24:22 +0100
commit37330d7288126b917d2e3ccab70400705f99c05d (patch)
treeb2f33cc5810210adb1c624c1d24e5834a2f196b1 /python
parentpython: client: completion: use argparse.REMAINDER (diff)
downloadknot-resolver-37330d7288126b917d2e3ccab70400705f99c05d.tar.xz
knot-resolver-37330d7288126b917d2e3ccab70400705f99c05d.zip
kresctl: tab-completion: auto-complete for all commands except config
Diffstat (limited to 'python')
-rw-r--r--python/knot_resolver/client/commands/convert.py4
-rw-r--r--python/knot_resolver/client/commands/metrics.py4
-rw-r--r--python/knot_resolver/client/commands/schema.py5
-rw-r--r--python/knot_resolver/client/commands/validate.py4
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: