forked from clan/clan-core
Merge pull request 'clan/improve/dynamic-completions-config' (#1558) from kenji/clan-core:clan/improve/dynamic-completions-config into main
Reviewed-on: clan/clan-core#1558
This commit is contained in:
commit
c6fcb833b3
@ -9,6 +9,7 @@ from pathlib import Path
|
||||
from typing import Any, get_origin
|
||||
|
||||
from clan_cli.cmd import run
|
||||
from clan_cli.completions import add_dynamic_completer, complete_machines
|
||||
from clan_cli.dirs import machine_settings_file
|
||||
from clan_cli.errors import ClanError
|
||||
from clan_cli.git import commit_file
|
||||
@ -317,13 +318,14 @@ def register_parser(
|
||||
|
||||
# inject callback function to process the input later
|
||||
parser.set_defaults(func=get_option)
|
||||
parser.add_argument(
|
||||
set_machine_action = parser.add_argument(
|
||||
"--machine",
|
||||
"-m",
|
||||
help="Machine to configure",
|
||||
type=str,
|
||||
default="default",
|
||||
)
|
||||
add_dynamic_completer(set_machine_action, complete_machines)
|
||||
|
||||
parser.add_argument(
|
||||
"--show-trace",
|
||||
|
@ -3,6 +3,7 @@ import json
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
from ..completions import add_dynamic_completer, complete_machines
|
||||
from ..machines.machines import Machine
|
||||
|
||||
|
||||
@ -45,5 +46,6 @@ def inspect_command(args: argparse.Namespace) -> None:
|
||||
|
||||
|
||||
def register_inspect_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument("machine", type=str, default="defaultVM")
|
||||
machine_action = parser.add_argument("machine", type=str, default="defaultVM")
|
||||
add_dynamic_completer(machine_action, complete_machines)
|
||||
parser.set_defaults(func=inspect_command)
|
||||
|
@ -8,6 +8,7 @@ from pathlib import Path
|
||||
from tempfile import TemporaryDirectory
|
||||
|
||||
from ..cmd import Log, run
|
||||
from ..completions import add_dynamic_completer, complete_machines
|
||||
from ..dirs import module_root, user_cache_dir, vm_state_dir
|
||||
from ..errors import ClanError
|
||||
from ..facts.generate import generate_facts
|
||||
@ -205,5 +206,8 @@ def run_command(
|
||||
|
||||
|
||||
def register_run_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument("machine", type=str, help="machine in the flake to run")
|
||||
machine_action = parser.add_argument(
|
||||
"machine", type=str, help="machine in the flake to run"
|
||||
)
|
||||
add_dynamic_completer(machine_action, complete_machines)
|
||||
parser.set_defaults(func=lambda args: run_command(**args.__dict__))
|
||||
|
Loading…
Reference in New Issue
Block a user