fix(B-0272): accept hyphen-prefixed ROM option values#2168
Merged
Conversation
Remove the startsWith("-") guard from readOptionValue so paths
like --dir -roms are parsed correctly instead of rejected.
Update test to use a truly missing value (trailing --datfile
with no argument).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
parseArgs now throws ArgError instead of calling process.exit, so main() catches and returns the exit code. Tests no longer need to monkeypatch process.exit. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Codex <noreply@openai.com>
1f2de9d to
903333d
Compare
There was a problem hiding this comment.
Pull request overview
Updates the ROM canonicalizer CLI to correctly accept option values that begin with - (e.g., --datfile -set.dat, --dir -roms) by treating only an actually-absent value as missing, and routes parse errors back through main() so the module is more testable and composable.
Changes:
- Adjust CLI arg parsing to accept hyphen-prefixed option values and propagate parse failures via
main()return codes instead ofprocess.exitinside parsing. - Implement bounded-memory SHA1 hashing using a fixed-size read buffer rather than reading whole files at once.
- Add regression tests covering hyphen-prefixed values and clearer missing-value error reporting.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tools/roms/canonicalize.ts | CLI parsing behavior updated; hashing switched to streaming reads; small path handling tweak for rename targets. |
| tools/roms/canonicalize.test.ts | Adds focused CLI regression tests and updates scan expectations for extensionless/non-ROM files. |
| docs/backlog/P1/B-0272-atari-rom-canonical-naming-tosec-lookup-2026-05-08.md | Updates last_updated date for the backlog item. |
Comments suppressed due to low confidence (1)
tools/roms/canonicalize.test.ts:22
- Test fixture MD5 value looks like 31 hex chars (MD5 should be 32). Even though the parser doesn’t validate MD5, keeping fixtures structurally valid avoids confusing future readers/debugging. Consider changing it to a 32-char hex string or omitting the md5 attribute entirely in the fixture.
<game name="Combat (1977)(Atari)">
<description>Combat (1977)(Atari)</description>
<rom name="Combat (1977)(Atari).bin" size="2048" crc="4020b4fe" md5="b35e9442525e1a0b30dc0264c112233" sha1="da39a3ee5e6b4b0d3255bfef95601890afd80709" />
</game>
Co-Authored-By: Codex <noreply@openai.com>
AceHack
added a commit
that referenced
this pull request
May 16, 2026
…th pure-drift this session) (#3820) 10th pure-drift close of the resume-session sequence. All 3 acceptance items verifiably shipped via PRs #2166 + #2168 + #2172: - Script at tools/roms/canonicalize.ts (8953 bytes) - TOSEC + No-Intro matching via Logiqx XML - Rename + unmatched-hash reporting Surfaced by peer Otto's audit-backlog-status-drift.ts (PR #3758); per-acceptance verification confirmed pure-drift. Co-authored-by: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--datfile -set.datand--dir -romsby treating only absent option values as missingmain()instead of callingprocess.exitinsideparseArgsTests
bun test tools/roms/canonicalize.test.tsgit diff --checkCoordination
Follow-up to the merged #2166 review thread. This intentionally keeps the older
claim/b0272-rom-canonical-naming-smallest-slice-2026-05-08single-quote parser branch out of scope so it can be handled separately or retired deliberately.