From e650165e80294fc66d88b0ff5451b5617bb8bff9 Mon Sep 17 00:00:00 2001 From: Leo Kettmeir Date: Fri, 14 Jan 2022 17:38:17 +0100 Subject: chore: upgrade clap to v3 (#13266) --- cli/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'cli/main.rs') diff --git a/cli/main.rs b/cli/main.rs index b845a4f49..c996425c7 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -1376,7 +1376,11 @@ fn unwrap_or_exit(result: Result) -> T { match result { Ok(value) => value, Err(error) => { - eprintln!("{}: {:?}", colors::red_bold("error"), error); + eprintln!( + "{}: {}", + colors::red_bold("error"), + format!("{:?}", error).trim_start_matches("error: ") + ); std::process::exit(1); } } @@ -1404,11 +1408,10 @@ pub fn main() { let flags = match flags::flags_from_vec(args) { Ok(flags) => flags, Err(err @ clap::Error { .. }) - if err.kind == clap::ErrorKind::HelpDisplayed - || err.kind == clap::ErrorKind::VersionDisplayed => + if err.kind == clap::ErrorKind::DisplayHelp + || err.kind == clap::ErrorKind::DisplayVersion => { - err.write_to(&mut std::io::stdout()).unwrap(); - std::io::stdout().write_all(b"\n").unwrap(); + err.print().unwrap(); std::process::exit(0); } Err(err) => unwrap_or_exit(Err(AnyError::from(err))), -- cgit v1.2.3