Merge pull request 'always provide a clan_flake_toplevel value' (#620) from Mic92-main into main
This commit is contained in:
@@ -32,12 +32,20 @@ async def inspect_vm(flake_url: str | Path, flake_attr: str) -> VmConfig:
|
|||||||
return VmConfig(flake_url=flake_url, flake_attr=flake_attr, **data)
|
return VmConfig(flake_url=flake_url, flake_attr=flake_attr, **data)
|
||||||
|
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class InspectOptions:
|
||||||
|
machine: str
|
||||||
|
flake: Path
|
||||||
|
|
||||||
|
|
||||||
def inspect_command(args: argparse.Namespace) -> None:
|
def inspect_command(args: argparse.Namespace) -> None:
|
||||||
if args.flake is None:
|
inspect_options = InspectOptions(
|
||||||
flake = Path.cwd()
|
machine=args.machine,
|
||||||
else:
|
flake=args.flake or Path.cwd(),
|
||||||
flake = Path(args.flake)
|
)
|
||||||
res = asyncio.run(inspect_vm(flake_url=flake, flake_attr=args.machine))
|
res = asyncio.run(
|
||||||
|
inspect_vm(flake_url=inspect_options.flake, flake_attr=inspect_options.machine)
|
||||||
|
)
|
||||||
print("Cores:", res.cores)
|
print("Cores:", res.cores)
|
||||||
print("Memory size:", res.memory_size)
|
print("Memory size:", res.memory_size)
|
||||||
print("Graphics:", res.graphics)
|
print("Graphics:", res.graphics)
|
||||||
|
|||||||
@@ -273,16 +273,19 @@ def run_vm(
|
|||||||
class RunOptions:
|
class RunOptions:
|
||||||
machine: str
|
machine: str
|
||||||
flake_url: str | None
|
flake_url: str | None
|
||||||
|
flake: Path
|
||||||
nix_options: list[str] = field(default_factory=list)
|
nix_options: list[str] = field(default_factory=list)
|
||||||
flake: Path | None = None
|
|
||||||
|
|
||||||
|
|
||||||
def run_command(args: argparse.Namespace) -> None:
|
def run_command(args: argparse.Namespace) -> None:
|
||||||
run_options = RunOptions(args.machine, args.flake_url, args.option, args.flake)
|
run_options = RunOptions(
|
||||||
|
machine=args.machine,
|
||||||
|
flake_url=args.flake_url,
|
||||||
|
flake=args.flake or Path.cwd(),
|
||||||
|
nix_options=args.option,
|
||||||
|
)
|
||||||
|
|
||||||
flake_url = run_options.flake_url or run_options.flake
|
flake_url = run_options.flake_url or run_options.flake
|
||||||
if not flake_url:
|
|
||||||
flake_url = Path.cwd()
|
|
||||||
vm = asyncio.run(inspect_vm(flake_url=flake_url, flake_attr=run_options.machine))
|
vm = asyncio.run(inspect_vm(flake_url=flake_url, flake_attr=run_options.machine))
|
||||||
|
|
||||||
run_vm(vm, run_options.nix_options)
|
run_vm(vm, run_options.nix_options)
|
||||||
|
|||||||
Reference in New Issue
Block a user