Skip to content

Commit 354f8ed

Browse files
committed
Harden automation launch parsing
1 parent 4809fcb commit 354f8ed

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

SCRATCHPAD.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,4 @@
120120
- README was refreshed to reflect the SDL/Win64 release path, the macOS-plus-Windows packaging assets, and the new tag/manual-only release workflow.
121121
- SDL editor exit now fully consumes its close key; leaving the in-game SDL editor no longer forwards `Q` or `Esc` into the live session and accidentally traps the run in pause mode.
122122
- The old ANSI terminal frontend was removed; the project is now graphics-only, with `--terminal` retained only as a legacy alias that falls back to the native graphics path.
123+
- Automation was already independent of the removed terminal frontend; launch parsing is now hardened so `--sdl` / `--graphics` / `--terminal` cannot override `--script`, `--bridge`, or `--editor` when those non-interactive modes are selected.

Sources/Game/App/AutomationControl.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,10 @@ struct LaunchOptions: Equatable {
4040
let arg = arguments[index]
4141
switch arg {
4242
case "--terminal":
43-
target = .interactive
4443
graphicsBackend = .native
4544
case "--graphics":
46-
target = .interactive
4745
graphicsBackend = .native
4846
case "--sdl":
49-
target = .interactive
5047
graphicsBackend = .sdl
5148
case "--editor":
5249
target = .editor

Tests/GameTests/CoreGameTests.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ import Testing
9898
#expect(options.graphicsBackend == .sdl)
9999
}
100100

101+
@Test func launchOptionsDoNotLetGraphicsFlagsOverrideNonInteractiveModes() async throws {
102+
let scriptOptions = try LaunchOptions.parse(arguments: ["Game", "--script", "state", "--sdl"])
103+
#expect(scriptOptions.target == .script)
104+
#expect(scriptOptions.graphicsBackend == .sdl)
105+
#expect(scriptOptions.commands == ["state"])
106+
107+
let bridgeOptions = try LaunchOptions.parse(arguments: ["Game", "--bridge", "--sdl"])
108+
#expect(bridgeOptions.target == .bridge)
109+
#expect(bridgeOptions.graphicsBackend == .sdl)
110+
111+
let editorOptions = try LaunchOptions.parse(arguments: ["Game", "--editor", "--sdl"])
112+
#expect(editorOptions.target == .editor)
113+
#expect(editorOptions.graphicsBackend == .sdl)
114+
}
115+
101116
@Test func graphicsVisualThemeCyclesBetweenModes() async throws {
102117
#expect(GraphicsVisualTheme.gemstone.next() == .ultima)
103118
#expect(GraphicsVisualTheme.ultima.next() == .depth3D)

0 commit comments

Comments
 (0)