Improve clap error message
This commit is contained in:
parent
f4b47fbe12
commit
e9e6fa6c6f
16
src/main.rs
16
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<std::io::Error> for KakMessage {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<clap::Error> 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<String> for KakMessage {
|
||||
fn from(err: String) -> Self {
|
||||
Self(err, None)
|
||||
|
Loading…
Reference in New Issue
Block a user