use std::fmt;
#[derive(Debug)]
pub struct UsageError(pub String);
impl fmt::Display for UsageError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(&self.0)
}
}
impl std::error::Error for UsageError {}
#[derive(Debug, Clone, Copy)]
pub enum ExitCode {
Success = 0,
Usage = 1,
IoError = 2,
ToggleError = 3,
#[allow(dead_code)]
Internal = 4,
}
impl ExitCode {
pub fn posix(self) -> i32 {
match self {
Self::Success => 0, Self::Usage => 64, Self::IoError => 74, Self::ToggleError => 70, Self::Internal => 71, }
}
pub fn code(self) -> i32 {
self as i32
}
}