pkgs/cli: Complete --target-host flag

This commit is contained in:
a-kenji
2024-11-10 19:12:54 +01:00
parent 81d39e00e1
commit 7ab1707ab9
2 changed files with 15 additions and 4 deletions

View File

@@ -10,7 +10,11 @@ from tempfile import TemporaryDirectory
from clan_cli.api import API from clan_cli.api import API
from clan_cli.clan_uri import FlakeId from clan_cli.clan_uri import FlakeId
from clan_cli.cmd import Log, run from clan_cli.cmd import Log, run
from clan_cli.completions import add_dynamic_completer, complete_machines from clan_cli.completions import (
add_dynamic_completer,
complete_machines,
complete_target_host,
)
from clan_cli.facts.generate import generate_facts from clan_cli.facts.generate import generate_facts
from clan_cli.machines.hardware import HardwareConfig from clan_cli.machines.hardware import HardwareConfig
from clan_cli.machines.machines import Machine from clan_cli.machines.machines import Machine
@@ -233,10 +237,11 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None:
"--json", "--json",
help="specify the json file for ssh data (generated by starting the clan installer)", help="specify the json file for ssh data (generated by starting the clan installer)",
) )
group.add_argument( target_host_parser = group.add_argument(
"--target-host", "--target-host",
help="ssh address to install to in the form of user@host:2222", help="ssh address to install to in the form of user@host:2222",
) )
add_dynamic_completer(target_host_parser, complete_target_host)
group.add_argument( group.add_argument(
"-P", "-P",
"--png", "--png",

View File

@@ -8,7 +8,11 @@ import sys
from clan_cli.api import API from clan_cli.api import API
from clan_cli.clan_uri import FlakeId from clan_cli.clan_uri import FlakeId
from clan_cli.cmd import run from clan_cli.cmd import run
from clan_cli.completions import add_dynamic_completer, complete_machines from clan_cli.completions import (
add_dynamic_completer,
complete_machines,
complete_target_host,
)
from clan_cli.errors import ClanError from clan_cli.errors import ClanError
from clan_cli.facts.generate import generate_facts from clan_cli.facts.generate import generate_facts
from clan_cli.facts.upload import upload_secrets from clan_cli.facts.upload import upload_secrets
@@ -217,11 +221,13 @@ def register_update_parser(parser: argparse.ArgumentParser) -> None:
help="Host key (.ssh/known_hosts) check mode.", help="Host key (.ssh/known_hosts) check mode.",
) )
parser.add_argument( target_host_parser = parser.add_argument(
"--target-host", "--target-host",
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.",
) )
add_dynamic_completer(target_host_parser, complete_target_host)
parser.add_argument( parser.add_argument(
"--darwin", "--darwin",
type=str, type=str,