mirror of
https://github.com/sharkdp/fd.git
synced 2024-11-16 08:58:26 +01:00
31 lines
674 B
Rust
31 lines
674 B
Rust
pub enum ExitCode {
|
|
Success,
|
|
GeneralError,
|
|
KilledBySigint,
|
|
}
|
|
|
|
impl Into<i32> for ExitCode {
|
|
fn into(self) -> i32 {
|
|
match self {
|
|
ExitCode::Success => 0,
|
|
ExitCode::GeneralError => 1,
|
|
ExitCode::KilledBySigint => 130,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl ExitCode {
|
|
pub fn error_if_any_error(results: Vec<Self>) -> Self {
|
|
if results.iter().any(ExitCode::is_error) {
|
|
return ExitCode::GeneralError;
|
|
}
|
|
ExitCode::Success
|
|
}
|
|
|
|
fn is_error(&self) -> bool {
|
|
match self {
|
|
ExitCode::GeneralError | ExitCode::KilledBySigint => true,
|
|
_ => false,
|
|
}
|
|
}
|
|
}
|