Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #131 #133

Merged
merged 2 commits into from
May 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Argument `--length` silently takes precedence over `--bytes`, see #105
- Print warning on empty content, see #107 and #108
- Disallow block sizes of zero, see #110
- Fix newline appearing in `--version` output, see #131 and #133 (@scimas)

## Other

Expand Down
13 changes: 9 additions & 4 deletions src/bin/hexyl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down