]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
kresctl: tab-completion: display config keywords in config completion docs-develop-kres-ph09xl/deployments/5365
authorFrantisek Tobias <frantisek.tobias@nic.cz>
Fri, 18 Oct 2024 11:26:10 +0000 (13:26 +0200)
committerFrantisek Tobias <frantisek.tobias@nic.cz>
Fri, 18 Oct 2024 11:39:58 +0000 (13:39 +0200)
python/knot_resolver/client/command.py
python/knot_resolver/client/commands/completion.py
python/knot_resolver/client/commands/config.py
python/knot_resolver/constants.py

index b0ae38ccdbb8c2d14430b8058102976812544632..e0a0c13e9335cfd620f234dfc484f6041b6075c3 100644 (file)
@@ -141,7 +141,7 @@ class Command(ABC):
     @staticmethod
     def completion(parser: argparse.ArgumentParser, args: Optional[List[str]]) -> CompWords:
         words: CompWords = get_subparsers_words(parser._actions)  # Get subparser words
-        if args is None or args == ['']:
+        if args is None or args == [""]:
             return words
 
         subparsers = parser._subparsers
@@ -153,13 +153,12 @@ class Command(ABC):
                 uarg = args[i]
                 subparser = get_subparser_by_name(uarg, subparsers._actions)  # pylint: disable=W0212
 
-                # print(f"uarg: {uarg}, {args}, {words}\n")
                 if subparser:
                     try:
                         cmd = get_subparser_command(subparser)
                         subparser_args = args[i + 1 :]
                         words = cmd.completion(subparser, subparser_args)
-                    except:
+                    except ValueError:
                         return get_subparsers_words(subparser._actions)
 
                     break
index cffd7e0df0b5af42063fec2bc5af8b120f98cc50..b7a804d89b3dd4de9ba24089dcc63cdb32dbd003 100644 (file)
@@ -2,16 +2,7 @@ import argparse
 from enum import Enum
 from typing import List, Tuple, Type
 
-from knot_resolver.client.command import (
-    Command,
-    CommandArgs,
-    CompWords,
-    get_subparser_by_name,
-    get_subparser_command,
-    get_subparsers_words,
-    register_command,
-)
-from knot_resolver.client.commands.config import ConfigCommand
+from knot_resolver.client.command import Command, CommandArgs, register_command
 
 
 class Shells(Enum):
index 8523cf2bf6e7d6b12d3675a173216921eaa305b8..5d0b5c74beb9bf03aea1cbc2aaebd4921bff236e 100644 (file)
@@ -3,10 +3,17 @@ import sys
 from enum import Enum
 from typing import Any, Dict, List, Literal, Optional, Tuple, Type
 
-from knot_resolver.client.command import Command, CommandArgs, CompWords, register_command, get_subparser_by_name, get_subparsers_words
+from knot_resolver.client.command import (
+    Command,
+    CommandArgs,
+    CompWords,
+    get_subparser_by_name,
+    get_subparsers_words,
+    register_command,
+)
+from knot_resolver.datamodel import KresConfig
 from knot_resolver.utils.modeling.parsing import DataFormat, parse_json, try_to_parse
 from knot_resolver.utils.requests import request
-from knot_resolver.datamodel import KresConfig
 
 
 class Operations(Enum):
@@ -228,7 +235,6 @@ class ConfigCommand(Command):
 
         return words
 
-
     def run(self, args: CommandArgs) -> None:
         if not self.operation:
             args.subparser.print_help()
index 567be9f7fc69e293ef624d365a57eb90e562a278..2acb86603574f604271bf3a9fb520af7047eb294 100644 (file)
@@ -1,14 +1,14 @@
 from pathlib import Path
 
 VERSION = "6.0.8"
-USER = "ftobias"
-GROUP = "ftobias"
+USER = "knot-resolver"
+GROUP = "knot-resolver"
 
 # dirs paths
-RUN_DIR = Path("/home/ftobias/knot_projects/knot-resolver/.install_dev/run/knot-resolver")
-ETC_DIR = Path("/home/ftobias/knot_projects/knot-resolver/.install_dev/etc/knot-resolver")
-SBIN_DIR = Path("/home/ftobias/knot_projects/knot-resolver/.install_dev/sbin")
-CACHE_DIR = Path("/home/ftobias/knot_projects/knot-resolver/.install_dev/var/cache/knot-resolver")
+RUN_DIR = Path("/run/knot-resolver")
+ETC_DIR = Path("/etc/knot-resolver")
+SBIN_DIR = Path("/usr/sbin")
+CACHE_DIR = Path("/var/cache/knot-resolver")
 
 # files paths
 CONFIG_FILE = ETC_DIR / "config.yaml"