Clan-cli: remove unused show machine
This commit is contained in:
@@ -6,7 +6,6 @@ from .delete import register_delete_parser
|
|||||||
from .hardware import register_hw_generate
|
from .hardware import register_hw_generate
|
||||||
from .install import register_install_parser
|
from .install import register_install_parser
|
||||||
from .list import register_list_parser
|
from .list import register_list_parser
|
||||||
from .show import register_show_parser
|
|
||||||
from .update import register_update_parser
|
from .update import register_update_parser
|
||||||
|
|
||||||
|
|
||||||
@@ -86,17 +85,6 @@ For more detailed information, visit: https://docs.clan.lol/getting-started/conf
|
|||||||
)
|
)
|
||||||
register_hw_generate(generate_hw_parser)
|
register_hw_generate(generate_hw_parser)
|
||||||
|
|
||||||
show_parser = subparser.add_parser(
|
|
||||||
"show",
|
|
||||||
help="Show a machine",
|
|
||||||
epilog=(
|
|
||||||
"""
|
|
||||||
This subcommand shows the details of a machine managed by this clan like icon, description, etc
|
|
||||||
"""
|
|
||||||
),
|
|
||||||
)
|
|
||||||
register_show_parser(show_parser)
|
|
||||||
|
|
||||||
install_parser = subparser.add_parser(
|
install_parser = subparser.add_parser(
|
||||||
"install",
|
"install",
|
||||||
help="Install a machine",
|
help="Install a machine",
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
import argparse
|
|
||||||
import dataclasses
|
|
||||||
import json
|
|
||||||
import logging
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
from clan_cli.api import API
|
|
||||||
|
|
||||||
from ..cmd import run_no_stdout
|
|
||||||
from ..completions import add_dynamic_completer, complete_machines
|
|
||||||
from ..nix import nix_config, nix_eval
|
|
||||||
from .types import machine_name_type
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
@dataclasses.dataclass
|
|
||||||
class MachineInfo:
|
|
||||||
machine_name: str
|
|
||||||
machine_description: str | None
|
|
||||||
machine_icon: str | None
|
|
||||||
|
|
||||||
|
|
||||||
@API.register
|
|
||||||
def show_machine(flake_url: str | Path, machine_name: str) -> MachineInfo:
|
|
||||||
config = nix_config()
|
|
||||||
system = config["system"]
|
|
||||||
cmd = nix_eval(
|
|
||||||
[
|
|
||||||
f"{flake_url}#clanInternals.machines.{system}.{machine_name}",
|
|
||||||
"--apply",
|
|
||||||
"machine: { inherit (machine.config.clan.core) machineDescription machineIcon machineName; }",
|
|
||||||
"--json",
|
|
||||||
]
|
|
||||||
)
|
|
||||||
proc = run_no_stdout(cmd)
|
|
||||||
res = proc.stdout.strip()
|
|
||||||
machine = json.loads(res)
|
|
||||||
|
|
||||||
return MachineInfo(
|
|
||||||
machine_name=machine.get("machineName"),
|
|
||||||
machine_description=machine.get("machineDescription", None),
|
|
||||||
machine_icon=machine.get("machineIcon", None),
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def show_command(args: argparse.Namespace) -> None:
|
|
||||||
machine = show_machine(args.flake.path, args.machine)
|
|
||||||
print(f"Name: {machine.machine_name}")
|
|
||||||
print(f"Description: {machine.machine_description or ''}")
|
|
||||||
print(f"Icon: {machine.machine_icon or ''}")
|
|
||||||
|
|
||||||
|
|
||||||
def register_show_parser(parser: argparse.ArgumentParser) -> None:
|
|
||||||
parser.set_defaults(func=show_command)
|
|
||||||
machine_parser = parser.add_argument(
|
|
||||||
"machine", help="the name of the machine", type=machine_name_type
|
|
||||||
)
|
|
||||||
add_dynamic_completer(machine_parser, complete_machines)
|
|
||||||
Reference in New Issue
Block a user