"""Command to verify `patches/gui/` against `gui.vromfs.bin` with Quirrel bytecode compilation. wtotools check-gui --gui [--patches patches/gui] [--sq build/quirrel-check/sq.exe] """ from __future__ import annotations import argparse import sys from pathlib import Path from ..gui_check import verify_gui_patches DEFAULT_GUI_PATCHES = Path("patches/gui") DEFAULT_SQ_EXE = Path("build/quirrel-check/sq.exe") def register(commands: argparse._SubParsersAction) -> None: check = commands.add_parser( "check-gui", help="apply patches/gui in memory and bytecode-compile every modified .nut script", ) check.add_argument("--gui", type=Path, required=True, help="stock gui.vromfs.bin to read") check.add_argument("--patches", type=Path, default=DEFAULT_GUI_PATCHES, help="patches/gui directory") check.add_argument("--sq", type=Path, default=DEFAULT_SQ_EXE, help="Quirrel compiler sq.exe path") check.set_defaults(handler=_check_gui) def _check_gui(args: argparse.Namespace) -> int: if not args.sq.exists(): print(f"Quirrel compiler not found: {args.sq}", file=sys.stderr) return 2 report = verify_gui_patches(args.gui, args.patches, args.sq) print(f"{report.patches_applied} GUI patch(es) applied across {report.files_checked} .nut file(s)") if report.errors: for error in report.errors: print(f" {error}", file=sys.stderr) return 1 print(" every patched .nut file compiled to Quirrel bytecode with zero lexical/constant errors") return 0