pkgs/cli: Validate clan directory for update-hardware-config

This commit is contained in:
a-kenji
2025-07-15 19:11:07 +02:00
committed by pinpox
parent 5b651752ba
commit 26fdfeec00
2 changed files with 19 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ import argparse
import logging
from pathlib import Path
from clan_lib.flake import require_flake
from clan_lib.machines.hardware import (
HardwareConfig,
HardwareGenerateOptions,
@@ -19,8 +20,9 @@ log = logging.getLogger(__name__)
def update_hardware_config_command(args: argparse.Namespace) -> None:
validate_machine_names([args.machine], args.flake)
machine = Machine(flake=args.flake, name=args.machine)
flake = require_flake(args.flake)
validate_machine_names([args.machine], flake)
machine = Machine(flake=flake, name=args.machine)
opts = HardwareGenerateOptions(
machine=machine,
password=args.password,

View File

@@ -0,0 +1,15 @@
from pathlib import Path
import pytest
from clan_lib.errors import ClanError
from clan_cli.tests.helpers import cli
def test_create_command_no_flake(
tmp_path: Path, monkeypatch: pytest.MonkeyPatch
) -> None:
monkeypatch.chdir(tmp_path)
with pytest.raises(ClanError):
cli.run(["machines", "update-hardware-config", "machine"])