From edd8d3c45705ec20b13d9ab8970fb30bec7b2aa2 Mon Sep 17 00:00:00 2001 From: RyujiYasukochi Date: Sat, 28 Feb 2026 22:15:26 +0900 Subject: [PATCH 1/2] 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 --- src/cmp.rs | 5 ++++- src/params.rs | 5 ++++- tests/integration.rs | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/cmp.rs b/src/cmp.rs index 1db866b..8a49fac 100644 --- a/src/cmp.rs +++ b/src/cmp.rs @@ -217,7 +217,10 @@ pub fn parse_params>(mut opts: Peekable) -> 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); diff --git a/src/params.rs b/src/params.rs index 921a397..2545307 100644 --- a/src/params.rs +++ b/src/params.rs @@ -195,7 +195,10 @@ pub fn parse_params>(mut opts: Peekable) -> 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); diff --git a/tests/integration.rs b/tests/integration.rs index c9db571..cf376ca 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -39,8 +39,8 @@ 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(()) From e6a28ea7791c746f00cdf37848ead3e6ba5e5afe Mon Sep 17 00:00:00 2001 From: RyujiYasukochi Date: Sat, 28 Feb 2026 22:16:46 +0900 Subject: [PATCH 2/2] style: apply cargo fmt formatting Co-Authored-By: Claude Opus 4.6 --- src/cmp.rs | 5 +---- src/params.rs | 5 +---- tests/integration.rs | 4 +--- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/cmp.rs b/src/cmp.rs index 8a49fac..09ba368 100644 --- a/src/cmp.rs +++ b/src/cmp.rs @@ -217,10 +217,7 @@ pub fn parse_params>(mut opts: Peekable) -> Resu std::process::exit(0); } if param_str.starts_with('-') { - return Err(format!( - "unrecognized option '{}'", - param.to_string_lossy() - )); + return Err(format!("unrecognized option '{}'", param.to_string_lossy())); } if from.is_none() { from = Some(param); diff --git a/src/params.rs b/src/params.rs index 2545307..74ef3e3 100644 --- a/src/params.rs +++ b/src/params.rs @@ -195,10 +195,7 @@ pub fn parse_params>(mut opts: Peekable) -> Resu Err(error) => return Err(error), } if param.to_string_lossy().starts_with('-') { - return Err(format!( - "unrecognized option '{}'", - param.to_string_lossy() - )); + return Err(format!("unrecognized option '{}'", param.to_string_lossy())); } if from.is_none() { from = Some(param); diff --git a/tests/integration.rs b/tests/integration.rs index cf376ca..0e8d21e 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -39,9 +39,7 @@ mod common { cmd.assert() .code(predicate::eq(2)) .failure() - .stderr(predicate::str::contains( - "unrecognized option '--foobar'", - )); + .stderr(predicate::str::contains("unrecognized option '--foobar'")); } Ok(()) }