feat: default to build command when no subcommand is given

This commit is contained in:
Konstantin Fickel 2026-02-20 20:29:03 +01:00
parent 4def49350e
commit 1f75c72a96
Signed by: kfickel
GPG key ID: A793722F9933C1A5

View file

@ -5,10 +5,11 @@ from __future__ import annotations
import asyncio import asyncio
import time import time
from pathlib import Path from pathlib import Path
from typing import Annotated from typing import Annotated, override
import click import click
import typer import typer
from typer.core import TyperGroup
from hokusai.builder import BuildEvent, BuildResult, run_build from hokusai.builder import BuildEvent, BuildResult, run_build
from hokusai.config import ProjectConfig, load_config 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.providers.registry import get_all_models
from hokusai.state import state_filename 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" _CONFIG_SUFFIX = ".hokusai.yaml"