Don't print the error for version output, instead add a newline print.
Move the eprint for help only.
This commit is contained in:
Mihir Gadgil authored and David Peter committed 2021-05-07 10:05:16 +02:00
1 parent 642eff6061
commit 532eab762d
1 file changed
+9 -4
+9 -4
View File
@@ -235,13 +235,18 @@ fn main() {
if let Err(err) = result {
if let Some(clap_err) = err.downcast_ref::<clap::Error>() {
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 {