From 532eab762d7d1d4c70b1fcefd0c7af7b4b33a9a6 Mon Sep 17 00:00:00 2001 From: Mihir Gadgil Date: Thu, 22 Apr 2021 23:15:35 -0600 Subject: [PATCH] Fix #131 Don't print the error for version output, instead add a newline print. Move the eprint for help only. --- src/bin/hexyl.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/hexyl.rs b/src/bin/hexyl.rs index 5243bca..71a9999 100644 --- a/src/bin/hexyl.rs +++ b/src/bin/hexyl.rs @@ -235,13 +235,18 @@ fn main() { if let Err(err) = result { if let Some(clap_err) = err.downcast_ref::() { - eprint!("{}", clap_err); // Clap errors already have newlines - match clap_err.kind { // The exit code should not indicate an error for --help / --version - clap::ErrorKind::HelpDisplayed | clap::ErrorKind::VersionDisplayed => { + clap::ErrorKind::HelpDisplayed => { + eprint!("{}", clap_err); // Clap errors already have newlines std::process::exit(0) - } + }, + clap::ErrorKind::VersionDisplayed => { + // Version output in clap 2.33.1 (dep as of now) doesn't have a newline + // and the fix is not included even in the latest stable release + println!(""); + std::process::exit(0) + }, _ => (), } } else {