CLI: rpf and shaders refuse an option they cannot read, and a typo #2303
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2303
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2303/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@b3IKK on GitHub · 2026-11-25 13:17 UTC · original
b3IKK:cli/refuse-unknown-options→main· +282 −30 · 4 files · 1 commits · closed without mergingFixes #2266.
xcl rpfandxcl shadersread their options by position and dropped whatever they did not understand, so a mistake changed what the command did while it still exited 0:xcl rpf pkg.rpf --extract(no value) listed instead of extracting;xcl rpf pkg.rpf --fnid foofiltered nothing and listed everything;xcl rpf pkg.rpf --top abctook the default of 30;xcl shaders pack --hash 0xZZmeant "no filter", i.e. the whole corpus swept, which looks like it is working and can take hours;xcl shaders --compile x,--threads x,--timeout x… all took their defaults.xcl disasmalready refuses such values; this gives the other two the same behaviour.Since the review (@nnonno91 ran the binary): the options that only one branch of
xcl shadersuses were still checked inside that branch, so on a path that never reached it (--threads abcon an empty folder,--onlywithout--precompile) the run printed the summary and exited 0, and a bad option after a missing input was reported after the file error rather than before it. Every value option is now checked at the top ofrun, before anything is read — the four cases at the bottom of the table above.A small
crates/xcl/src/cli.rsnow does the reading:text(an option whose value is missing or is another option is an error),number(decimal or0xhexadecimal),hex_u64(--hash), andunknown(an argument starting with-that the subcommand does not know).xcl rpf's parsing moved into anoptions()that returnsResult, so both the option set and the values are testable;xcl shadersvalidates its option list and every numeric option at the top ofrun, before anything is read, so a typo costs no I/O or translation.What is in it
crates/xcl/src/cli.rs(new): the helpers above, with unit tests for a missing value, a value that is another option, decimal/hexadecimal numbers, a bad hash, and an unknown option.crates/xcl/src/rpf.rs:options()->Result<Options, String>(--top,--find,--extract,--out,--full,--probe), used byrun; testan_unknown_or_unreadable_option_is_an_error.crates/xcl/src/shaders.rs: the known-option list, every numeric option (--top,--compile,--windows,--min-kb,--count,--split,--repeat,--limit,--sample,--seed,--threads,--max-bytes,--timeout) and the value options--example,--only,--dump,--hashread strictly; testa_typo_or_an_unreadable_number_is_refused.Tested
stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1).\scripts\test.ps1(cargo build --workspace+cargo test --workspace -- --test-threads=4): 1248 passed, 0 failed, 46 ignored (SKIPPED: the wave64 / direct-DXIL per-lane tests that need 64-lane hardware or a semantics mode this adapter refuses,no heap windows, andcannot disable the driver cache (Windows Developer Mode is required))cli::tests3,rpf::tests::an_unknown_or_unreadable_option_is_an_error1,shaders::tests::a_typo_or_an_unreadable_number_is_refused1 — all pass; the shaders test fails with the unknown-option check taken out (an unknown option is not ignored)xcl rpf no-such.rpf --top abcxcl rpf: invalid value for --top: abcxcl rpf no-such.rpf --fnid fooxcl rpf: unknown option --fnid; seexcl --help``xcl rpf no-such.rpf --extractxcl rpf: --extract needs a valuexcl shaders no-such --top abcxcl shaders: invalid value for --top: abcxcl shaders <file> --direct --hash 0xZZxcl shaders: invalid value for --hash: 0xZZxcl shaders no-such --fnid xxcl shaders: unknown option --fnid; seexcl --help``xcl shaders <empty folder> --threads abcxcl shaders: invalid value for --threads: abcxcl shaders <empty folder> --timeout abcxcl shaders: invalid value for --timeout: abcxcl shaders <empty folder> --onlyxcl shaders: --only needs a valuexcl shaders <empty folder> --max-bytes xxcl shaders: invalid value for --max-bytes: x(The "before" column is the behaviour the issue describes from the source; I ran only the new binary.)
Regression run
main (
426a5a7, clean tree, no local changes):PR (
8d1544f, clean tree, no local changes):Not tested
scripts/andtests/do not pass an option these changes now refuse (the workspace suite passes), but a contributor's own command line with an option I forgot to list would now be refused instead of ignored — the list isOPTIONSincrates/xcl/src/shaders.rsand theKNOWNlist inrpf::optionsxcl --help's usage text, which still omits some flags: that is #2216AI use
xcl rpf's parsing into a testableoptions(), madexcl shadersstrict, wrote the tests (and confirmed the shaders one fails without the change), ran the suite, the binary's cases above and thescripts/smoke.ps1pair.@b3IKK on GitHub · 2026-11-25 14:22 UTC · original
Thank you — all four are real holes in what I pushed, and the branch-local placement is exactly why they happened.
Pushed
8d1544f: every value option ofxcl shadersis validated at the top ofrunbefore the input is read, including--threads,--timeout,--max-bytes,--sample,--seed,--split,--onlyand--dump. On an empty folder:xcl shaders <empty> --threads abcinvalid value for --threads: abcxcl shaders <empty> --timeout abcinvalid value for --timeout: abcxcl shaders <empty> --only--only needs a valuexcl shaders <empty> --max-bytes xinvalid value for --max-bytes: xThe unit test now covers the empty-folder case for each of those. Suite on this head: 1248 passed, 0 failed, 46 ignored; smoke blocks for
426a5a7and8d1544fare in the description. AI use: OpenCode, Claude Fable 5.2.@nnonno91 on GitHub · 2026-11-25 14:04 UTC · original · edited 2026-11-25 14:32 UTC
@b3IKK I retested the updated CLI and confirmed all eight checks below. Thanks for the fix.
Retest on
8d1544f55ba246a8be0ee60dcaa8e18afe1c86c0The previous failures below are resolved in this retest. I rebuilt the clean head with
cargo build --locked -p xcl --bin xclon the same Windows and Rust setup. On an empty folder,--threads abc,--timeout abc,--onlyand--max-bytes xeach exited 2 with the option-specific error. On a nonexistent input,--direct --threads abc,--direct --timeout abcand--precompile --only --pipelineseach exited 2 with the option error before the missing-file error could occur. The valid-options control (--direct --threads 2 --timeout 10) reached the expected missing-file diagnostic. All eight CLI assertions passed. No game, GPU or workspace-suite run. OpenAI Codex (GPT-6.2 Sol) ran and reported the retest.I ran the actual CLI on this head and found that some malformed shader options still exit successfully, or are checked only after input I/O.
Tested
d8e8a93822a7e9ab204ec1e36bf7f7d797ff5f9f. Windows 11 25H2 build 26200.9974, Ryzen 7 9800X3D, Rust 1.100.0 MSVC, unoptimizedcargo build --locked -p xcl --bin xcl. Used an empty temporary directory and a nonexistent file inside it.xcl rpf <missing> --extract,--top abc,--fnid foo, and--typoeach exited 2 with an option-specific diagnostic.xcl shaders <missing> --hash 0xZZand--typodid the same.xcl shaders <empty> --threads abc,--timeout abc, and--onlyeach exited 0 and printed the normal empty-folder summary. With--direct, the first two exited 2 with their numeric diagnostics on the empty directory. With--precompile --only --pipelines, the empty directory gave--only needs a value.xcl shaders <missing> --direct --threads abc,--direct --timeout abc, and--precompile --only --pipelineseach exited 2 with the file-not-found message before reaching the bad option. Those cases still differ from the description's validation before reading input.Not tested
Real archive contents, game runs, GPU translation, and the full workspace suite.
AI use
OpenAI Codex (GPT-6.2 Sol) ran the CLI checks and wrote this report.
@throny on GitHub · 2026-11-25 15:07 UTC · original
Two contributors checked independently and found that #2285 solves the same problem (for #2266) in a different way: #1607, group D78. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
@itsonewi on GitHub · 2026-11-25 15:56 UTC · original
Heads-up on coordination: #2285 also fixes #2266 and creates the same new file (
crates/xcl/src/cli.rs) with a different API, so the two cannot both merge. There is a side-by-side comparison of the two PRs on #2266 (options, exit codes, tests, changed lines), including one factual difference in this PR:unknown()walks every argument, values included, so a value that begins with a single dash is reported as an unknown option - the unit test above it comments "values are not looked at", which the implementation does not match. Where--prefixed values are rejected earlier bytext(), so it only bites on single-dash values.Nothing here needs an action beyond deciding that case; the rest is so the work is not lost to a rebase.
AI use: read both patches and the current
mainthrough the GitHub API for that comparison; no code was written by an agent here and no build was run.@b3IKK on GitHub · 2026-11-25 16:02 UTC · original
Closing in favour of #2285, which fixes #2266 and was opened at 12:26Z, before this one (13:17Z) - per the one-PR-per-change rule the earlier author's fix is the one to merge.
Its single-pass
Parseralso replaces the per-optionargs.iter().position(..)lookups instead of wrapping them, and it has end-to-end coverage intests/rpf_e2e.rs/tests/shaders_e2e.rs; its checks are green.The
unknown()inconsistency in this branch is real: it walks values too, while the unit test above it says values are not looked at; values starting with--are caught earlier bytext(), so only a single-dash value is affected. No action is needed here - #2285's parser does not have that shape.AI use: OpenCode, Claude Fable 5.2 read the comparison on #2266 and #2285's checks and wrote this.
@DavidM1911 on GitHub · 2026-11-25 17:41 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
github-bot referenced this pull request2026-11-26 06:18:31 +00:00
Pull request closed