Merge pull request 'cli: register update command' (#131) from Mic92-mic92 into main
All checks were successful
build / test (push) Successful in 21s
All checks were successful
build / test (push) Successful in 21s
This commit is contained in:
commit
3edd686996
@ -1,7 +1,7 @@
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from . import admin, config, secrets
|
||||
from . import admin, config, secrets, update
|
||||
from .errors import ClanError
|
||||
from .ssh import cli as ssh_cli
|
||||
|
||||
@ -17,10 +17,10 @@ def main() -> None:
|
||||
parser = argparse.ArgumentParser(description="cLAN tool")
|
||||
subparsers = parser.add_subparsers()
|
||||
|
||||
parser_admin = subparsers.add_parser("admin")
|
||||
parser_admin = subparsers.add_parser("admin", help="administrate a clan")
|
||||
admin.register_parser(parser_admin)
|
||||
|
||||
parser_config = subparsers.add_parser("config")
|
||||
parser_config = subparsers.add_parser("config", help="set nixos configuration")
|
||||
config.register_parser(parser_config)
|
||||
|
||||
parser_ssh = subparsers.add_parser("ssh", help="ssh to a remote machine")
|
||||
@ -29,6 +29,11 @@ def main() -> None:
|
||||
parser_secrets = subparsers.add_parser("secrets", help="manage secrets")
|
||||
secrets.register_parser(parser_secrets)
|
||||
|
||||
parser_update = subparsers.add_parser(
|
||||
"update", help="update the machines in the clan"
|
||||
)
|
||||
update.register_parser(parser_update)
|
||||
|
||||
if has_argcomplete:
|
||||
argcomplete.autocomplete(parser)
|
||||
|
||||
|
@ -18,32 +18,6 @@ def create(args: argparse.Namespace) -> None:
|
||||
)
|
||||
|
||||
|
||||
def rebuild(args: argparse.Namespace) -> None:
|
||||
# TODO get clients from zerotier cli?
|
||||
if args.host:
|
||||
print(f"would redeploy {args.host} from clan {args.folder}")
|
||||
else:
|
||||
print(f"would redeploy all hosts from clan {args.folder}")
|
||||
|
||||
|
||||
def destroy(args: argparse.Namespace) -> None:
|
||||
# TODO get clan folder & hosts from somwhere (maybe ~/.config/clan/$name /)
|
||||
# send some kind of kill signal, then remove the folder
|
||||
if args.yes:
|
||||
print(f"would remove {args.folder}")
|
||||
else:
|
||||
print(
|
||||
"are you really sure? this is non reversible and destructive, add --yes to confirm"
|
||||
)
|
||||
|
||||
|
||||
def backup(args: argparse.Namespace) -> None:
|
||||
if args.host:
|
||||
print(f"would backup {args.host} from clan {args.folder}")
|
||||
else:
|
||||
print(f"would backup all hosts from clan {args.folder}")
|
||||
|
||||
|
||||
def git(args: argparse.Namespace) -> None:
|
||||
subprocess.Popen(
|
||||
[
|
||||
@ -73,31 +47,6 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser_create = subparser.add_parser("create", help="create a new clan")
|
||||
parser_create.set_defaults(func=create)
|
||||
|
||||
parser_rebuild = subparser.add_parser(
|
||||
"rebuild", help="build configuration of a clan and push it to the target"
|
||||
)
|
||||
parser_rebuild.add_argument(
|
||||
"--host", help="specify single host to rebuild", default=None
|
||||
)
|
||||
parser_rebuild.set_defaults(func=rebuild)
|
||||
|
||||
parser_destroy = subparser.add_parser(
|
||||
"destroy", help="destroy a clan, including all the machines"
|
||||
)
|
||||
parser_destroy.add_argument(
|
||||
"--yes", help="specify single host to rebuild", action="store_true"
|
||||
)
|
||||
parser_destroy.set_defaults(func=destroy)
|
||||
|
||||
parser_backup = subparser.add_parser(
|
||||
"backup",
|
||||
help="backup all the state of all machines in a clan or just a single one",
|
||||
)
|
||||
parser_backup.add_argument(
|
||||
"--host", help="specify single host to rebuild", default=None
|
||||
)
|
||||
parser_backup.set_defaults(func=backup)
|
||||
|
||||
parser_git = subparser.add_parser("git", help="control the clan repo via git")
|
||||
parser_git.add_argument("git_args", nargs="*")
|
||||
parser_git.set_defaults(func=git)
|
||||
|
@ -96,9 +96,9 @@ def update(args: argparse.Namespace) -> None:
|
||||
def register_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_mutually_exclusive_group(required=True)
|
||||
# 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=".#", desc="nix flake uri")
|
||||
parser.add_argument("--flake-uri", type=str, default=".#", help="nix flake uri")
|
||||
parser.add_argument(
|
||||
"--flake-attr", type=str, description="nixos configuration in the flake"
|
||||
"--flake-attr", type=str, help="nixos configuration in the flake"
|
||||
)
|
||||
parser.add_argument("--user", type=str, default="root")
|
||||
parser.add_argument("host", type=str)
|
||||
|
Loading…
Reference in New Issue
Block a user