Skip to content
This repository was archived by the owner on Oct 9, 2026. It is now read-only.

Let clap handle --, the debug subcommand and value names - #57

Merged
sidkmenon merged 4 commits into
cli/no-config-flagfrom
cli/clap-parsing
Sep 30, 2026
Merged

sidkmenon merged 4 commits into
cli/no-config-flagfrom
cli/clap-parsing

Conversation

@sidkmenon

Copy link
Copy Markdown
Contributor

Stack created with GitHub Stacks CLI • Give Feedback 💬

Behavior change: a trailing `last = true` positional takes everything after
`--`, replacing the argv surgery before parsing.
- `diffr config -- foo` passes `foo` as the settings search; it was dropped.
- `diffr config show -- x` is rejected; `x` was dropped.
- Usage lines gain `[-- <paths>...]`.

A scan for `--` remains: git reads an argument before a bare trailing `--`
as a revision even when a file shares its name, and clap does not report an
empty trailing group.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change: main no longer checks argv[1] == "debug"; clap routes
`debug` like `config`. So `diffr --stat debug ...` enters debug and ignores
--stat, where it was "unknown revision or path". The next commit rejects
that for both subcommands.

DebugArgs derives Args and hangs off Command::Debug, hidden from --help,
with the same version string and usage line as before.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change: `diffr --cached config show` now fails with "the argument
'--cached' cannot be used with the 'config' subcommand"; the flag was
silently ignored. Likewise for `debug`.

clap's args_conflicts_with_subcommands does not fit: once any top-level
flag is given it reads the subcommand's name as a positional. Instead,
check after parsing whether any top-level argument came from the command
line, and raise clap's ArgumentConflict.

AI assistance: Claude Code.

Agent-Session: b28d94c6-2325-41ab-9fab-e9027acc5b09
Agent-Session: 01a0e9c2-2c41-7062-b484-92e030c4ab9c
Behavior change, help and errors only for the names: `<repo>` becomes
`<REPO>`, `[items]...` becomes `[ITEMS]...` (or `<ITEMS>...` in conflict
usage lines), and so on. `--repo` is a PathBuf, so a non-UTF-8 path is
accepted instead of rejected.

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 parsing Let clap handle --, the debug subcommand and value names Sep 30, 2026
@sidkmenon
sidkmenon merged commit 54f4135 into main Sep 30, 2026
46 checks passed
@thesiti92 thesiti92 mentioned this pull request Sep 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant