Files
Claude-Code-Game-Studios/.claude/scripts/godot-parse-check.gd
T
DonchitosandClaude Opus 5.5 b21fa0f7f2 Release 1.1.2 — the default path works end to end
Fix release for 1.1.1: the minimal path end to end, engine commands that
run on Godot, Unity and Unreal, hook warnings you can see, and verdicts
that say when they could not check. Details in CHANGELOG.md; upgrade
steps in UPGRADING.md (v1.1.1 → v1.1.2).

Fixes #67
Fixes #131

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WuJn2FdynEybfL5KC697nJ
2026-09-29 21:32:19 +10:00

34 lines
1.2 KiB
GDScript

extends SceneTree
## Parse-checks Godot scripts the way the game loads them.
##
## Usage, from the project root, after `godot --headless --path . --import`
## (which builds the class cache that `class_name` lookups need):
##
## godot --headless --path . -s res://.claude/scripts/godot-parse-check.gd -- res://src/a.gd res://src/b.gd
##
## Prints `ok: <path>` or `PARSE FAIL: <path>` per script, with Godot's own
## error lines above each failure. Exit 0 when every script loads, 1 when any
## does not, 2 when no script was given.
##
## Why not `--check-only`: it compiles the file with no autoloads
## registered, so valid code that names an autoload exits 1 with
## "Identifier not found". Loading in `_initialize()` runs after startup has
## registered them; `_init()` runs before, and fails the same way.
func _initialize() -> void:
var paths := OS.get_cmdline_user_args()
if paths.is_empty():
printerr("godot-parse-check: no scripts given. Pass res:// paths after `--`.")
quit(2)
return
var failed := 0
for path in paths:
var script := load(path) as Script
if script == null or not script.can_instantiate():
printerr("PARSE FAIL: ", path)
failed += 1
else:
print("ok: ", path)
quit(1 if failed > 0 else 0)