diff --git a/src/main.rs b/src/main.rs index 787fd31..013f435 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,12 +44,7 @@ fn send_message(msg: &KakMessage) { } fn run() -> Result<(), KakMessage> { - let options = Options::try_parse().map_err(|e| { - KakMessage( - "Error parsing arguments".to_string(), - Some(format!("Could not parse: {:?}", e)), - ) - })?; + let options = Options::try_parse()?; let replacement_re = options.regex; @@ -116,6 +111,15 @@ impl From for KakMessage { } } +impl From for KakMessage { + fn from(err: clap::Error) -> Self { + Self( + "Error parsing arguments".to_string(), + Some(format!("{:?}", err)), // Some(err.message.pieces.map(|p| p.0).join()), + ) + } +} + impl From for KakMessage { fn from(err: String) -> Self { Self(err, None)