Repository navigation
fix(ptx-schedule): the usage line brackets an option the CLI requires - #1136
Merged
nihalpasham merged 2 commits intoAug 23, 2026
Merged
nihalpasham merged 2 commits into
nihalpasham merged 2 commits into
Conversation
NVIDIA#1109's review flagged this: the brackets mark `-o|--output` optional, but outside `--list-sites` the output path is required, and the binary exits with the usage message when it is missing. ptx-schedule INPUT.ptx [--list-sites] ... [-o|--output OUTPUT] ... One bracketed list cannot state this CLI's shape. `--output` is required to perturb and meaningless when listing, so bracketing it is wrong in one mode and misleading in the other. It becomes one line per invocation form, which is what `cuda-intrinsics-gen`'s usage text already does for the same reason: usage: ptx-schedule INPUT.ptx --list-sites print the schedule-sensitive sites as JSON; the options below are ignored ptx-schedule INPUT.ptx -o|--output OUTPUT [--seed N] [--intensity F] [--max-sleep-ns N] [--focus TEXT] [--decisions-json FILE] write a perturbed copy of INPUT.ptx to OUTPUT The second half of the same problem: every way to get the command line wrong printed the identical block with nothing said about which way. `usage_because` prefixes the reason, and the six copies of `args.next().unwrap_or_else(|| usage())` -- each meaning "this flag needs a value", none saying so -- become one `next_value` helper that names the flag. Before, all four of these printed the same wall of text; now: ptx-schedule error: an input PTX file is required ptx-schedule x.ptx --seed error: --seed needs a value ptx-schedule x.ptx --bogus error: unrecognized argument "--bogus" ptx-schedule x.ptx --seed 7 error: -o|--output is required unless --list-sites is given Exit code stays 2 in every case, and both working forms are unchanged -- verified against a real module: `--list-sites` prints the JSON, and `--seed 7 -o out.ptx` reports `sites=2 injected=2`. Two tests. The first turns NVIDIA#1109's hand-checked parity into an assertion: the usage text names exactly the long flags the parser accepts, both directions, reading the arms out of the source (an arm can name two spellings, `"-o" | "--output"`, so it takes every quoted flag on the line). The second pins the shape this PR is about -- `--output` is not bracketed on the form that requires it, and does not appear on the listing form. They fail respectively when a flag is dropped from the text and when the brackets are put back. The README needs no change: its two examples are already the two forms, one with `-o` and one without. Verified: 16 tests pass, fmt clean, `clippy --all-targets -- -D warnings` clean, `cargo doc --document-private-items` clean. Signed-off-by: Vyncint Ng <[email protected]>
Model list and rewrite as exclusive modes, reject malformed commands before file access, and exercise both valid forms through the binary. Signed-off-by: nihalp <[email protected]>
Collaborator
|
nihalpasham
approved these changes
Aug 23, 2026
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.
Follow-up to #1109, whose review flagged it: "the brackets mark the flag optional, but outside
--list-sitesthe output path is required (main.rs exits with the usage message when it is missing). Candidate for a later polish pass."What is wrong
One bracketed list cannot state this CLI's shape:
--outputis required to perturb and meaningless when listing, so bracketing it is wrong in one mode and misleading in the other.It becomes one line per invocation form, which is what
cuda-intrinsics-gen's usage text already does for the same reason:The second half of the same problem
Every way to get the command line wrong printed the identical block with nothing said about which way.
usage_becauseprefixes the reason, and the six copies ofargs.next().unwrap_or_else(|| usage())— each meaning "this flag needs a value", none saying so — become onenext_valuehelper that names the flag. Before, all four of these printed the same wall of text:Exit code stays 2 in every case. Both working forms are unchanged, verified against a real module:
--list-sitesprints the JSON, and--seed 7 -o out.ptxreportssites=2 injected=2.Verification
Two tests. The first turns #1109's hand-checked parity into an assertion: the usage text names exactly the long flags the parser accepts, both directions, reading the arms out of the source — an arm can name two spellings (
"-o" | "--output"), so it takes every quoted flag on the line. The second pins the shape this PR is about:--outputis not bracketed on the form that requires it, and does not appear on the listing form. They fail respectively when a flag is dropped from the text and when the brackets are put back.The README needs no change — its two examples are already the two forms, one with
-oand one without.16 tests pass, fmt clean,
clippy --all-targets -- -D warningsclean,cargo doc --document-private-itemsclean. One file; no open PR touches it.Maintainer repair