mv update command to machines update command
This commit is contained in:
parent
80d3349ce0
commit
56542ca5ef
@ -3,7 +3,7 @@ import sys
|
|||||||
from types import ModuleType
|
from types import ModuleType
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from . import admin, secrets, update, webui
|
from . import admin, machines, secrets, webui
|
||||||
|
|
||||||
# from . import admin, config, secrets, update, webui
|
# from . import admin, config, secrets, update, webui
|
||||||
from .errors import ClanError
|
from .errors import ClanError
|
||||||
@ -34,10 +34,10 @@ def main() -> None:
|
|||||||
parser_secrets = subparsers.add_parser("secrets", help="manage secrets")
|
parser_secrets = subparsers.add_parser("secrets", help="manage secrets")
|
||||||
secrets.register_parser(parser_secrets)
|
secrets.register_parser(parser_secrets)
|
||||||
|
|
||||||
parser_update = subparsers.add_parser(
|
parser_machine = subparsers.add_parser(
|
||||||
"update", help="update the machines in the clan"
|
"machines", help="Manage machines and their configuration"
|
||||||
)
|
)
|
||||||
update.register_parser(parser_update)
|
machines.register_parser(parser_machine)
|
||||||
|
|
||||||
parser_webui = subparsers.add_parser("webui", help="start webui")
|
parser_webui = subparsers.add_parser("webui", help="start webui")
|
||||||
webui.register_parser(parser_webui)
|
webui.register_parser(parser_webui)
|
||||||
|
17
pkgs/clan-cli/clan_cli/machines/__init__.py
Normal file
17
pkgs/clan-cli/clan_cli/machines/__init__.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# !/usr/bin/env python3
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
from .update import register_update_parser
|
||||||
|
|
||||||
|
|
||||||
|
# takes a (sub)parser and configures it
|
||||||
|
def register_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
|
subparser = parser.add_subparsers(
|
||||||
|
title="command",
|
||||||
|
description="the command to run",
|
||||||
|
help="the command to run",
|
||||||
|
required=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
groups_parser = subparser.add_parser("update", help="Update a machine")
|
||||||
|
register_update_parser(groups_parser)
|
@ -2,7 +2,7 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
from .ssh import Host, HostGroup, HostKeyCheck
|
from ..ssh import Host, HostGroup, HostKeyCheck
|
||||||
|
|
||||||
|
|
||||||
def deploy_nixos(hosts: HostGroup) -> None:
|
def deploy_nixos(hosts: HostGroup) -> None:
|
||||||
@ -94,7 +94,7 @@ def update(args: argparse.Namespace) -> None:
|
|||||||
deploy_nixos(HostGroup([Host(args.host, user=args.user, meta=meta)]))
|
deploy_nixos(HostGroup([Host(args.host, user=args.user, meta=meta)]))
|
||||||
|
|
||||||
|
|
||||||
def register_parser(parser: argparse.ArgumentParser) -> None:
|
def register_update_parser(parser: argparse.ArgumentParser) -> None:
|
||||||
# TODO pass all args we don't parse into ssh_args, currently it fails if arg starts with -
|
# TODO pass all args we don't parse into ssh_args, currently it fails if arg starts with -
|
||||||
parser.add_argument("--flake-uri", type=str, default=".#", help="nix flake uri")
|
parser.add_argument("--flake-uri", type=str, default=".#", help="nix flake uri")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
@ -8,12 +8,12 @@ import pytest
|
|||||||
from environment import mock_env
|
from environment import mock_env
|
||||||
from host_group import HostGroup
|
from host_group import HostGroup
|
||||||
|
|
||||||
from clan_cli.update import deploy_nixos, register_parser
|
from clan_cli.machines.update import deploy_nixos, register_update_parser
|
||||||
|
|
||||||
|
|
||||||
def test_cli() -> None:
|
def test_cli() -> None:
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
register_parser(parser)
|
register_update_parser(parser)
|
||||||
with pytest.raises(SystemExit):
|
with pytest.raises(SystemExit):
|
||||||
parser.parse_args(["--help"])
|
parser.parse_args(["--help"])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user