"""Transport for the `godot` domain — args in, delegate, format out.""" from __future__ import annotations import typer from tooling.core import cli, console from tooling.core.command import command from tooling.core.errors import ReachError from tooling.domains.godot import service from tooling.domains.godot.schemas import ParseResult app = cli.domain("godot", "Does the client parse, and does it parse cold.") @app.callback() def _domain() -> None: """Keeps `godot` a group (Typer collapses a single-command app).""" def _verdict(result: ParseResult, name: str, clean: str) -> None: """Shared rendering — three failure shapes, three different remedies.""" if result.engine_failed: raise ReachError( f"{name}: godot itself exited {result.engine_exit} — not a parse verdict\n" + "\n".join(f" {line}" for line in result.lines), fix="the engine failed rather than the code; check the Godot install " "with `godot --version`, or make setup-godot", exit_code=result.engine_exit, ) if result.did_not_run: raise ReachError( f"{name}: the sweep did not report completion — no verdict possible\n" + "\n".join(f" {line}" for line in result.lines), fix="client/tools/parse_sweep.gd did not run to completion; a check " "that examined nothing must not report clean", ) if result.lines: shown = result.lines[:40] raise ReachError( f"{name}: at least one script does not parse\n" + "\n".join(f" {line}" for line in shown) + (f"\n {result.summary}" if result.summary else ""), fix="an unparseable file cannot run — if it is a test suite it did " "not execute, and any pass count reported elsewhere excludes it", ) console.verdict(clean) @app.command("parse-sweep") @command def parse_sweep() -> None: """Open every project .gd and fail on any that will not parse.""" result = service.parse_sweep() _verdict( result, "godot-parse-sweep", f"godot-parse-sweep: clean — {result.summary.removeprefix('parse-sweep: ')}", ) @app.command("cold-parse") @command def cold_parse( run_menu: bool = typer.Option( False, "--run-menu", help="Also launch main_menu.tscn briefly, for UI branches." ), ) -> None: """Cold-cache startup parse — the class_name/autoload registration race.""" _verdict(service.cold_parse(run_menu), "godot-cold-parse", "godot-cold-parse: clean")