Skip to content

fix(error): suggest removing -- when a known flag follows it#6370

Open
kimjune01 wants to merge 2 commits into
clap-rs:masterfrom
kimjune01:fix/3604-suggest-remove-double-dash
Open

fix(error): suggest removing -- when a known flag follows it#6370
kimjune01 wants to merge 2 commits into
clap-rs:masterfrom
kimjune01:fix/3604-suggest-remove-double-dash

Conversation

@kimjune01
Copy link
Copy Markdown

@kimjune01 kimjune01 commented May 9, 2026

When a user writes app -- --dev and --dev is a known flag, the error now suggests removing the -- separator instead of showing a generic unknown argument error.

Split per C-TEST: first commit reproduces the problem, second commit adds the fix.

Fixes #3604

@epage
Copy link
Copy Markdown
Member

epage commented May 9, 2026

I would recommend against AI PR descriptions as they focus on the wrong details.

Our contrib guide recommends a particular commit structure. You can read more about it at https://epage.github.io/dev/pr-style/#c-test

kimjune01 added 2 commits May 10, 2026 20:57
When the parser hits a flag-like arg after `--`, check if it
matches a known long or short flag.  If so, emit a contextual
error suggesting the user remove the separator.

Fixes clap-rs#3604
@kimjune01
Copy link
Copy Markdown
Author

Fair point — I've restructured the PR per your commit guidelines: test commit first (C-TEST), then the fix. Also rewrote the description. Let me know if this is closer to what you'd like.

@kimjune01 kimjune01 force-pushed the fix/3604-suggest-remove-double-dash branch from 1f55860 to e8ea665 Compare May 11, 2026 04:02
Comment thread tests/builder/error.rs

#[test]
#[cfg(feature = "error-context")]
fn flag_used_after_double_dash() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C-TEST says that this should be reproducing the undesired behavior and then the follow up commit should update the test for the new behavior.

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.

Suggest removing -- if specified, but unnecessary

2 participants