forked from clan/clan-core
fix black and ruff checks
This commit is contained in:
parent
926de547e2
commit
3ce01871e5
@ -2,14 +2,14 @@
|
||||
import argparse
|
||||
import sys
|
||||
|
||||
from . import admin
|
||||
|
||||
has_argcomplete = True
|
||||
try:
|
||||
import argcomplete
|
||||
except ImportError:
|
||||
has_argcomplete = False
|
||||
|
||||
from . import admin
|
||||
|
||||
|
||||
# this will be the entrypoint under /bin/clan (see pyproject.toml config)
|
||||
def main() -> None:
|
||||
@ -24,5 +24,6 @@ def main() -> None:
|
||||
if len(sys.argv) == 1:
|
||||
parser.print_help()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@ -34,7 +34,7 @@ def edit(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
)
|
||||
|
||||
|
||||
def rebuild(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
def rebuild(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
# TODO get clients from zerotier cli?
|
||||
if args.host:
|
||||
print(f"would redeploy {args.host} from clan {args.folder}")
|
||||
@ -42,7 +42,7 @@ def rebuild(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
print(f"would redeploy all hosts from clan {args.folder}")
|
||||
|
||||
|
||||
def destroy(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
def destroy(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
# TODO get clan folder & hosts from somwhere (maybe ~/.config/clan/$name /)
|
||||
# send some kind of kill signal, then remove the folder
|
||||
if args.yes:
|
||||
@ -53,22 +53,24 @@ def destroy(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
)
|
||||
|
||||
|
||||
def backup(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
def backup(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
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: # pragma: no cover
|
||||
def git(args: argparse.Namespace) -> None: # pragma: no cover
|
||||
subprocess.Popen(
|
||||
[
|
||||
"git",
|
||||
"-C",
|
||||
args.folder,
|
||||
] + args.git_args
|
||||
]
|
||||
+ args.git_args
|
||||
)
|
||||
|
||||
|
||||
# takes a (sub)parser and configures it
|
||||
def register_parser(parser: argparse.ArgumentParser) -> None:
|
||||
parser.add_argument(
|
||||
@ -107,7 +109,8 @@ def register_parser(parser: argparse.ArgumentParser) -> None:
|
||||
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"
|
||||
"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
|
||||
|
@ -7,6 +7,7 @@ def test_make_parser():
|
||||
parser = argparse.ArgumentParser()
|
||||
clan_admin.make_parser(parser)
|
||||
|
||||
|
||||
# using fp fixture from pytest-subprocess
|
||||
def test_create(fp):
|
||||
cmd = ["nix", "flake", "init", "-t", fp.any()]
|
||||
@ -14,4 +15,3 @@ def test_create(fp):
|
||||
args = argparse.Namespace(folder="./my-clan")
|
||||
clan_admin.create(args)
|
||||
assert fp.call_count(cmd) == 1
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user