2018-10-03 11:25:16 +02:00
|
|
|
pub enum ExitCode {
|
2019-09-13 22:26:27 +02:00
|
|
|
Success,
|
2018-10-03 15:27:53 +02:00
|
|
|
GeneralError,
|
|
|
|
KilledBySigint,
|
2018-10-03 11:25:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<i32> for ExitCode {
|
|
|
|
fn into(self) -> i32 {
|
|
|
|
match self {
|
2020-01-25 17:13:47 +01:00
|
|
|
Self::Success => 0,
|
|
|
|
Self::GeneralError => 1,
|
|
|
|
Self::KilledBySigint => 130,
|
2018-10-03 11:25:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-25 17:13:47 +01:00
|
|
|
|
|
|
|
impl ExitCode {
|
|
|
|
pub fn error_if_any_error(results: Vec<Self>) -> Self {
|
|
|
|
if results.iter().any(|s| match s {
|
|
|
|
Self::GeneralError => true,
|
|
|
|
_ => false,
|
|
|
|
}) {
|
|
|
|
return Self::GeneralError;
|
|
|
|
}
|
|
|
|
Self::Success
|
|
|
|
}
|
|
|
|
}
|