vitrify_cli/exit.rs
1//! The exit-code table. Every CLI error path maps through
2//! this enum; `main` is the only place that converts to a process exit.
3
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5#[repr(u8)]
6pub enum ExitCode {
7 /// Asserted state holds (recorded / clean / listed / published).
8 Ok = 0,
9 /// Unexpected error (git failure, I/O).
10 Error = 1,
11 /// Usage error, or a named check failed (audit/lint findings, an init or
12 /// probe FAIL, probe changes not applied).
13 Usage = 2,
14 /// Trace or projection mismatch (keys/units named on stdout).
15 Mismatch = 3,
16 /// Not found / precondition failed.
17 NotFound = 4,
18 /// Lost publish race after retries.
19 LostRace = 5,
20 /// Lease already expired (renew refused — re-claim instead).
21 LeaseExpired = 6,
22}
23
24impl ExitCode {
25 pub fn from_code(code: u8) -> ExitCode {
26 match code {
27 0 => ExitCode::Ok,
28 2 => ExitCode::Usage,
29 3 => ExitCode::Mismatch,
30 4 => ExitCode::NotFound,
31 5 => ExitCode::LostRace,
32 6 => ExitCode::LeaseExpired,
33 _ => ExitCode::Error,
34 }
35 }
36}