Skip to content

Validate CLI flags in clap and document every flag - #58

Merged
sidkmenon merged 8 commits into
cli/clap-parsingfrom
cli/clap-validation
Sep 30, 2026
Merged

sidkmenon merged 8 commits into
cli/clap-parsingfrom
cli/clap-validation

Conversation

@sidkmenon

Copy link
Copy Markdown
Contributor

Stack created with GitHub Stacks CLI • Give Feedback 💬

Behavior change: the checks after parsing only ran on the paths that
reached them; `diffr -z` opened the terminal UI, and the error surfaced
only when the UI ran diffr again. As clap attributes they apply to every
invocation, and the errors are clap's.
- --format conflicts with --quiet and each metadata output
- -z requires --name-only or --name-status
- --no-index conflicts with --cached, --merge-base, -z and metadata output
- --syntax requires --format, rather than being silently ignored

METADATA names the five outputs one by one: pointing a conflict at the
group makes clap list all five instead of the flag that was given.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change: clap rejects 0 with "number would be zero for non-zero
type", in place of the check that ran only after the diff session opened.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change: `--syntax --stat` and `--stream-annotations --quiet` are
rejected. clap waives `requires` when the required argument conflicts with
one that was given, so --format conflicting with --stat excused --syntax's
missing --format.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change, errors only: a malformed GLOB:LANG_NAME in --override or
DFT_OVERRIDE is a clap error naming the value and the reason, in place of
parse_overrides_or_die's own messages and process::exit.
DFT_OVERRIDE_1..9, read outside clap, share the parser and report in clap's
format with the variable's name; a non-UTF-8 value is an error rather than
silently skipped. Adjacent overrides naming one language still merge.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change: the four actions move into a flattened DebugAction struct
marked `#[group(required = true, multiple = false)]`. `diffr debug` with no
action is clap's "required arguments were not provided", and two actions
are rejected; they used to run whichever came first in a fixed order.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change, help text only. Every top-level flag without help gets a
doc comment, and the debug options' help strings become doc comments too:
clap drops their trailing periods in -h, and --override's first line is now
a summary, with its examples under --help.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
@sidkmenon
sidkmenon added this pull request to stack #59 September 30, 2026 16:28
@sidkmenon
sidkmenon marked this pull request as ready for review September 30, 2026 17:11
@sidkmenon sidkmenon changed the title cli/clap validation Validate CLI flags in clap and document every flag Sep 30, 2026
@sidkmenon
sidkmenon merged commit d2e03c3 into main Sep 30, 2026
46 checks passed
@thesiti92 thesiti92 mentioned this pull request Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant