]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
manager: client: 'help' cmd added
authorAleš Mrázek <ales.mrazek@nic.cz>
Tue, 13 Dec 2022 15:38:25 +0000 (16:38 +0100)
committerAleš Mrázek <ales.mrazek@nic.cz>
Tue, 10 Jan 2023 18:57:14 +0000 (19:57 +0100)
manager/knot_resolver_manager/cli/cmd/help.py [new file with mode: 0644]

diff --git a/manager/knot_resolver_manager/cli/cmd/help.py b/manager/knot_resolver_manager/cli/cmd/help.py
new file mode 100644 (file)
index 0000000..d374005
--- /dev/null
@@ -0,0 +1,24 @@
+import argparse
+from typing import List, Tuple, Type
+
+from knot_resolver_manager.cli.command import Command, CommandArgs, CompWords, register_command
+
+
+@register_command
+class HelpCommand(Command):
+    def __init__(self, namespace: argparse.Namespace) -> None:
+        super().__init__(namespace)
+
+    def run(self, args: CommandArgs) -> None:
+        args.parser.print_help()
+
+    @staticmethod
+    def completion(args: List[str], parser: argparse.ArgumentParser) -> CompWords:
+        return {}
+
+    @staticmethod
+    def register_args_subparser(
+        subparser: "argparse._SubParsersAction[argparse.ArgumentParser]",
+    ) -> Tuple[argparse.ArgumentParser, "Type[Command]"]:
+        stop = subparser.add_parser("help", help="show this help message and exit")
+        return stop, HelpCommand