Skip to content

Commit

Permalink
fix(Error Status): fixes bug where --help and --version return non-ze…
Browse files Browse the repository at this point in the history
…ro exit code
  • Loading branch information
kbknapp committed Nov 3, 2015
1 parent c748cef commit 89b51fd
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/app/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,19 @@ pub struct ClapError {
impl ClapError {
/// Prints the error to `stderr` and exits with a status of `1`
pub fn exit(&self) -> ! {
wlnerr!("{}", self.error);
process::exit(1);
if self.use_stderr() {
wlnerr!("{}", self.error);
process::exit(1);
}
println!("{}", self.error);
process::exit(0);
}

fn use_stderr(&self) -> bool {
match self.error_type {
ClapErrorType::HelpDisplayed | ClapErrorType::VersionDisplayed => false,
_ => true
}
}
}

Expand Down

0 comments on commit 89b51fd

Please sign in to comment.