add dummy backups cli

This commit is contained in:
lassulus
2023-11-28 13:23:48 +01:00
parent 640430075a
commit 4ace326aeb
5 changed files with 148 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
import argparse
import pprint
from pathlib import Path
from typing import Optional
from ..errors import ClanError
def create_backup(flake_dir: Path, machine: Optional[str] = None, provider: Optional[str] = None) -> None:
if machine is None:
# TODO get all machines here
machines = [ "machine1", "machine2" ]
else:
machines = [ machine ]
if provider is None:
# TODO get all providers here
providers = [ "provider1", "provider2" ]
else:
providers = [ provider ]
print("would create backups for machines: ", machines, " with providers: ", providers)
def create_command(args: argparse.Namespace) -> None:
if args.flake is None:
raise ClanError("Could not find clan flake toplevel directory")
create_backup(Path(args.flake), machine=args.machine, provider=args.provider)
def register_create_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument("--machine", type=str, help="machine in the flake to create backups of")
parser.add_argument("--provider", type=str, help="backup provider to use")
parser.set_defaults(func=create_command)