Skip to content

Commit 9dcca24

Browse files
Ryujiyasuclaude
andauthored
fix: match GNU error format for unrecognized options (#180)
* fix: match GNU error format for unrecognized options Use single quotes and remove colon to match GNU diff/cmp output: `unrecognized option '--foobar'` instead of `unrecognized option: "--foobar"` Also use `contains` instead of `starts_with` in the integration test to handle the command prefix (e.g. `cmp: unrecognized option ...`). Follow-up to #178 / #179. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style: apply cargo fmt formatting Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5660d0e commit 9dcca24

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

src/cmp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
217217
std::process::exit(0);
218218
}
219219
if param_str.starts_with('-') {
220-
return Err(format!("unrecognized option: {param:?}"));
220+
return Err(format!("unrecognized option '{}'", param.to_string_lossy()));
221221
}
222222
if from.is_none() {
223223
from = Some(param);

src/params.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
195195
Err(error) => return Err(error),
196196
}
197197
if param.to_string_lossy().starts_with('-') {
198-
return Err(format!("unrecognized option: {param:?}"));
198+
return Err(format!("unrecognized option '{}'", param.to_string_lossy()));
199199
}
200200
if from.is_none() {
201201
from = Some(param);

tests/integration.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ mod common {
3939
cmd.assert()
4040
.code(predicate::eq(2))
4141
.failure()
42-
.stderr(predicate::str::starts_with(
43-
"unrecognized option: \"--foobar\"",
44-
));
42+
.stderr(predicate::str::contains("unrecognized option '--foobar'"));
4543
}
4644
Ok(())
4745
}

0 commit comments

Comments
 (0)