From: Aleš Mrázek Date: Sun, 18 Sep 2022 19:48:52 +0000 (+0200) Subject: manager: kresctl: 'completion' command WIP X-Git-Tag: v6.0.0a1~12^2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4aedfdff61e40f4d81882baba5a669ab9dd0670f;p=thirdparty%2Fknot-resolver.git manager: kresctl: 'completion' command WIP --- diff --git a/manager/knot_resolver_manager/cli/cmd/completion.py b/manager/knot_resolver_manager/cli/cmd/completion.py new file mode 100644 index 000000000..601dd97ab --- /dev/null +++ b/manager/knot_resolver_manager/cli/cmd/completion.py @@ -0,0 +1,32 @@ +import argparse +from typing import Tuple, Type + +from knot_resolver_manager.cli.command import Command, CommandArgs, register_command + + +class Shells: + BASH = 0 + FISH = 1 + + +@register_command +class CompletionCommand(Command): + def __init__(self, namespace: argparse.Namespace) -> None: + super().__init__(namespace) + + @staticmethod + def register_args_subparser( + parser: "argparse._SubParsersAction[argparse.ArgumentParser]", + ) -> Tuple[argparse.ArgumentParser, "Type[Command]"]: + completion = parser.add_parser("completion", help="commands auto-completion") + + shells_dest = "shell" + shells = completion.add_mutually_exclusive_group() + shells.add_argument("--bash", action="store_const", dest=shells_dest, const=Shells.BASH, default=Shells.BASH) + shells.add_argument("--fish", action="store_const", dest=shells_dest, const=Shells.FISH) + + completion.add_argument("values_to_complete", type=str, nargs="+", help="values to auto-complete") + return completion, CompletionCommand + + def run(self, args: CommandArgs) -> None: + pass