diff --git a/hokusai/cli.py b/hokusai/cli.py index 95462f6..f58ad1b 100644 --- a/hokusai/cli.py +++ b/hokusai/cli.py @@ -9,10 +9,11 @@ from typing import Annotated, override import click import typer +import yaml from typer.core import TyperGroup from hokusai.builder import BuildEvent, BuildResult, run_build -from hokusai.config import ProjectConfig, load_config +from hokusai.config import GenerateTargetConfig, ProjectConfig, load_config from hokusai.graph import build_graph, get_build_order from hokusai.providers.registry import get_all_models from hokusai.state import state_filename @@ -255,16 +256,25 @@ def init() -> None: ) raise typer.Exit(code=1) - content = f"""\ -# {name} - hokusai project -targets: - great_wave.png: - prompt: >- - A recreation of Hokusai's "The Great Wave off Kanagawa", but instead of - boats and people, paint brushes, canvases, and framed paintings are - swimming and tumbling in the towering wave. -""" - _ = dest.write_text(content) + config = ProjectConfig( + targets={ + "great_wave.png": GenerateTargetConfig( + prompt=( + 'A recreation of Hokusai\'s "The Great Wave off Kanagawa",' + " but instead of boats and people, paint brushes, canvases," + " and framed paintings are swimming and tumbling in the" + " towering wave." + ), + ), + }, + ) + header = f"# {name} - hokusai project\n" + body = yaml.dump( + config.model_dump(exclude_defaults=True), + default_flow_style=False, + sort_keys=False, + ) + _ = dest.write_text(header + body) click.echo(click.style(" created ", fg="green") + click.style(filename, bold=True))