Merge pull request 'pkgs/cli: Autocomplete --build-host' (#5609) from ke-cli-complete-buildhost into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/5609
This commit is contained in:
@@ -478,6 +478,17 @@ def complete_tags(
|
|||||||
return dict.fromkeys(tags, "tag")
|
return dict.fromkeys(tags, "tag")
|
||||||
|
|
||||||
|
|
||||||
|
def complete_build_host(
|
||||||
|
prefix: str, # noqa: ARG001
|
||||||
|
_parsed_args: argparse.Namespace,
|
||||||
|
**_kwargs: Any,
|
||||||
|
) -> Iterable[str]:
|
||||||
|
"""Provides completion functionality for build host.
|
||||||
|
Returns 'localhost' as a suggestion while allowing arbitrary SSH addresses.
|
||||||
|
"""
|
||||||
|
return dict.fromkeys(["localhost"], "build_host")
|
||||||
|
|
||||||
|
|
||||||
def add_dynamic_completer(
|
def add_dynamic_completer(
|
||||||
action: argparse.Action,
|
action: argparse.Action,
|
||||||
completer: Callable[..., Iterable[str]],
|
completer: Callable[..., Iterable[str]],
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ from clan_lib.ssh.remote import Remote
|
|||||||
|
|
||||||
from clan_cli.completions import (
|
from clan_cli.completions import (
|
||||||
add_dynamic_completer,
|
add_dynamic_completer,
|
||||||
|
complete_build_host,
|
||||||
complete_machines,
|
complete_machines,
|
||||||
complete_tags,
|
complete_tags,
|
||||||
)
|
)
|
||||||
@@ -238,7 +239,7 @@ def register_update_parser(parser: argparse.ArgumentParser) -> None:
|
|||||||
type=str,
|
type=str,
|
||||||
help="Address of the machine to update, in the format of user@host:1234.",
|
help="Address of the machine to update, in the format of user@host:1234.",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
build_host_parser = parser.add_argument(
|
||||||
"--build-host",
|
"--build-host",
|
||||||
type=str,
|
type=str,
|
||||||
help=(
|
help=(
|
||||||
@@ -246,6 +247,7 @@ def register_update_parser(parser: argparse.ArgumentParser) -> None:
|
|||||||
"Pass 'localhost' to build on the local machine, or an ssh address like user@host:1234\n"
|
"Pass 'localhost' to build on the local machine, or an ssh address like user@host:1234\n"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
add_dynamic_completer(build_host_parser, complete_build_host)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--upload-inputs",
|
"--upload-inputs",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
|
|||||||
Reference in New Issue
Block a user