//! Exit codes that are part of the shell contract.
//!
//! `0` success, `1` failure, `2` usage (clap's own), `3` a probe or digest
//! refusal the operator must fix by hand (GDAL broken, boundary sha
//! mismatch). A verb returns this error type to leave with a code other
//! than `1`; `geolith_cli::exit_code` reads it back.
use std::fmt;
/// A process exit code other than the default `1`.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Exit(pub i32);
impl fmt::Display for Exit {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "exit {}", self.0)
}
}
impl std::error::Error for Exit {}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn an_exit_prints_its_code() {
assert_eq!(Exit(3).to_string(), "exit 3");
}
}