mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-12-28 10:40:48 +00:00
There’s more to erroneousness than an exit code
This commit is contained in:
parent
a060782312
commit
e4e603b4ee
@ -1,5 +1,5 @@
|
|||||||
extern crate exa;
|
extern crate exa;
|
||||||
use exa::{Exa, Misfire};
|
use exa::Exa;
|
||||||
|
|
||||||
use std::env::args_os;
|
use std::env::args_os;
|
||||||
use std::io::{stdout, stderr, Write, ErrorKind};
|
use std::io::{stdout, stderr, Write, ErrorKind};
|
||||||
@ -23,14 +23,14 @@ fn main() {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
Err(e@Misfire::Help(_)) | Err(e@Misfire::Version) => {
|
Err(ref e) if e.is_error() => {
|
||||||
writeln!(stdout(), "{}", e).unwrap();
|
writeln!(stderr(), "{}", e).unwrap();
|
||||||
exit(e.error_code());
|
exit(3);
|
||||||
},
|
},
|
||||||
|
|
||||||
Err(e) => {
|
Err(ref e) => {
|
||||||
writeln!(stderr(), "{}", e).unwrap();
|
writeln!(stdout(), "{}", e).unwrap();
|
||||||
exit(e.error_code());
|
exit(0);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -54,11 +54,11 @@ pub enum Misfire {
|
|||||||
impl Misfire {
|
impl Misfire {
|
||||||
|
|
||||||
/// The OS return code this misfire should signify.
|
/// The OS return code this misfire should signify.
|
||||||
pub fn error_code(&self) -> i32 {
|
pub fn is_error(&self) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
Misfire::Help(_) => 0,
|
Misfire::Help(_) => false,
|
||||||
Misfire::Version => 0,
|
Misfire::Version => false,
|
||||||
_ => 3,
|
_ => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user