From d772f5dcc5c362c8d2a097d19fff3a8737be2c91 Mon Sep 17 00:00:00 2001 From: Konstantin Fickel Date: Fri, 20 Feb 2026 20:33:10 +0100 Subject: [PATCH] feat: accept both .hokusai.yaml and .hokusai.yml config suffixes --- hokusai/cli.py | 17 +++++++++++------ tests/test_cli.py | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/hokusai/cli.py b/hokusai/cli.py index 7bda0f2..24f8cb4 100644 --- a/hokusai/cli.py +++ b/hokusai/cli.py @@ -32,7 +32,7 @@ app = typer.Typer( name="hokusai", help="AI artifact build tool.", cls=_DefaultBuildGroup ) -_CONFIG_SUFFIX = ".hokusai.yaml" +_CONFIG_SUFFIXES = (".hokusai.yaml", ".hokusai.yml") def _project_name(config_path: Path) -> str: @@ -41,16 +41,21 @@ def _project_name(config_path: Path) -> str: ``cards.hokusai.yaml`` → ``cards`` """ name = config_path.name - return name.removesuffix(_CONFIG_SUFFIX) + for suffix in _CONFIG_SUFFIXES: + if name.endswith(suffix): + return name.removesuffix(suffix) + return name def _find_config(directory: Path) -> Path: - """Find the single ``*.hokusai.yaml`` file in *directory*.""" - candidates = list(directory.glob("*.hokusai.yaml")) + """Find the single ``*.hokusai.{yaml,yml}`` file in *directory*.""" + candidates: list[Path] = [] + for suffix in _CONFIG_SUFFIXES: + candidates.extend(directory.glob(f"*{suffix}")) if len(candidates) == 0: click.echo( click.style("Error: ", fg="red", bold=True) - + "No .hokusai.yaml file found in current directory", + + "No .hokusai.yaml/.yml file found in current directory", err=True, ) raise typer.Exit(code=1) @@ -58,7 +63,7 @@ def _find_config(directory: Path) -> Path: names = ", ".join(str(c.name) for c in candidates) click.echo( click.style("Error: ", fg="red", bold=True) - + f"Multiple .hokusai.yaml files found: {names}", + + f"Multiple .hokusai.yaml/.yml files found: {names}", err=True, ) raise typer.Exit(code=1) diff --git a/tests/test_cli.py b/tests/test_cli.py index 1d2dca2..7750481 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -42,7 +42,7 @@ class TestFindConfig: mock_path_cls.cwd.return_value = tmp_path result = runner.invoke(app, ["build"]) assert result.exit_code != 0 - assert "No .hokusai.yaml file found" in result.output + assert "No .hokusai.yaml/.yml file found" in result.output def test_multiple_config_files(self, tmp_path: Path) -> None: _ = (tmp_path / "a.hokusai.yaml").write_text( @@ -55,7 +55,7 @@ class TestFindConfig: mock_path_cls.cwd.return_value = tmp_path result = runner.invoke(app, ["build"]) assert result.exit_code != 0 - assert "Multiple .hokusai.yaml files found" in result.output + assert "Multiple .hokusai.yaml/.yml files found" in result.output class TestBuildCommand: