fix(Error Status): fixes bug where --help and --version return non-zero exit code

This commit is contained in:
Kevin K 2015-11-02 22:56:05 -05:00
parent c748cef855
commit 89b51fdf8b

View file

@ -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
}
}
}