diff --git a/hokusai/cli.py b/hokusai/cli.py index 26e4ef5..7bda0f2 100644 --- a/hokusai/cli.py +++ b/hokusai/cli.py @@ -5,10 +5,11 @@ from __future__ import annotations import asyncio import time from pathlib import Path -from typing import Annotated +from typing import Annotated, override import click import typer +from typer.core import TyperGroup from hokusai.builder import BuildEvent, BuildResult, run_build from hokusai.config import ProjectConfig, load_config @@ -16,7 +17,20 @@ from hokusai.graph import build_graph, get_build_order from hokusai.providers.registry import get_all_models from hokusai.state import state_filename -app = typer.Typer(name="hokusai", help="AI artifact build tool.") + +class _DefaultBuildGroup(TyperGroup): # type: ignore[misc] + """Typer group that defaults to the 'build' command.""" + + @override + def parse_args(self, ctx: click.Context, args: list[str]) -> list[str]: + if not args or (args[0] not in self.commands and not args[0].startswith("-")): + args = ["build", *args] + return super().parse_args(ctx, args) + + +app = typer.Typer( + name="hokusai", help="AI artifact build tool.", cls=_DefaultBuildGroup +) _CONFIG_SUFFIX = ".hokusai.yaml"