mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-16 01:07:09 +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;
|
||||
use exa::{Exa, Misfire};
|
||||
use exa::Exa;
|
||||
|
||||
use std::env::args_os;
|
||||
use std::io::{stdout, stderr, Write, ErrorKind};
|
||||
@ -23,14 +23,14 @@ fn main() {
|
||||
};
|
||||
},
|
||||
|
||||
Err(e@Misfire::Help(_)) | Err(e@Misfire::Version) => {
|
||||
writeln!(stdout(), "{}", e).unwrap();
|
||||
exit(e.error_code());
|
||||
Err(ref e) if e.is_error() => {
|
||||
writeln!(stderr(), "{}", e).unwrap();
|
||||
exit(3);
|
||||
},
|
||||
|
||||
Err(e) => {
|
||||
writeln!(stderr(), "{}", e).unwrap();
|
||||
exit(e.error_code());
|
||||
Err(ref e) => {
|
||||
writeln!(stdout(), "{}", e).unwrap();
|
||||
exit(0);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -54,11 +54,11 @@ pub enum Misfire {
|
||||
impl Misfire {
|
||||
|
||||
/// The OS return code this misfire should signify.
|
||||
pub fn error_code(&self) -> i32 {
|
||||
pub fn is_error(&self) -> bool {
|
||||
match *self {
|
||||
Misfire::Help(_) => 0,
|
||||
Misfire::Version => 0,
|
||||
_ => 3,
|
||||
Misfire::Help(_) => false,
|
||||
Misfire::Version => false,
|
||||
_ => true,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user