Skip to content

Commit

Permalink
Merge branch 'kresctl-tab-completion-ignore-dash' into 'kresctl-tab-c…
Browse files Browse the repository at this point in the history
…ompletion'

python: client: completion: use argparse.REMAINDER

See merge request knot/knot-resolver!1630
  • Loading branch information
Frantisek Tobias committed Nov 15, 2024
2 parents cc05178 + 5b917b1 commit 9e3933a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions python/knot_resolver/client/commands/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def __init__(self, namespace: argparse.Namespace) -> None:
super().__init__(namespace)
self.shell: Shells = namespace.shell
self.space = namespace.space
self.comp_args: List[str] = namespace.comp_args
self.args: List[str] = namespace.args

if self.space:
self.comp_args.append("")
self.args.append("")

@staticmethod
def register_args_subparser(
Expand All @@ -36,18 +36,19 @@ def register_args_subparser(
action="store_true",
default=False,
)
completion.add_argument(
"comp_args",
type=str,
help="arguments to complete",
nargs="*",
)

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(
"--args",
help="arguments to complete",
nargs=argparse.REMAINDER,
default=[]
)

return completion, CompletionCommand

def run(self, args: CommandArgs) -> None:
Expand Down

0 comments on commit 9e3933a

Please sign in to comment.