API|CLI: Added argument 'flake_name' to all CLI and API endpoints. Tests missing.

This commit is contained in:
2023-10-13 22:29:55 +02:00
parent 740e5e2ebc
commit 06d6edbfa7
23 changed files with 195 additions and 105 deletions

View File

@@ -2,14 +2,14 @@ import argparse
import logging
import os
from .folders import machines_folder
from ..dirs import machines_dir
from .types import validate_hostname
log = logging.getLogger(__name__)
def list_machines() -> list[str]:
path = machines_folder()
def list_machines(flake_name: str) -> list[str]:
path = machines_dir(flake_name)
log.debug(f"Listing machines in {path}")
if not path.exists():
return []
@@ -21,9 +21,14 @@ def list_machines() -> list[str]:
def list_command(args: argparse.Namespace) -> None:
for machine in list_machines():
for machine in list_machines(args.flake):
print(machine)
def register_list_parser(parser: argparse.ArgumentParser) -> None:
parser.add_argument(
"flake",
type=str,
help="name of the flake to create machine for",
)
parser.set_defaults(func=list_command)