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>
This commit is contained in:
Ryuji Yasukochi
2026-03-10 19:48:58 +09:00
committed by GitHub
parent 5660d0eafb
commit 9dcca24fb0
3 changed files with 3 additions and 5 deletions
+1 -1
View File
@@ -217,7 +217,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
std::process::exit(0);
}
if param_str.starts_with('-') {
return Err(format!("unrecognized option: {param:?}"));
return Err(format!("unrecognized option '{}'", param.to_string_lossy()));
}
if from.is_none() {
from = Some(param);
+1 -1
View File
@@ -195,7 +195,7 @@ pub fn parse_params<I: Iterator<Item = OsString>>(mut opts: Peekable<I>) -> Resu
Err(error) => return Err(error),
}
if param.to_string_lossy().starts_with('-') {
return Err(format!("unrecognized option: {param:?}"));
return Err(format!("unrecognized option '{}'", param.to_string_lossy()));
}
if from.is_none() {
from = Some(param);
+1 -3
View File
@@ -39,9 +39,7 @@ mod common {
cmd.assert()
.code(predicate::eq(2))
.failure()
.stderr(predicate::str::starts_with(
"unrecognized option: \"--foobar\"",
));
.stderr(predicate::str::contains("unrecognized option '--foobar'"));
}
Ok(())
}