Skip to main content

ytcli/
exit.rs

1//! Process exit codes.
2//!
3//! Codes are part of the public contract: scripts and agents branch on them.
4//! Note what is deliberately *not* encoded here — "the result set was truncated"
5//! and "the result set was empty" are both success. Pagination state travels in
6//! the output text (see `docs/adr/0003-output-ladder.md`), never in the exit code.
7
8/// Exit code returned to the OS.
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10#[repr(u8)]
11pub enum ExitCode {
12    /// Command completed.
13    Success = 0,
14    /// Anything unexpected: I/O, transport, unhandled API error.
15    Failure = 1,
16    /// The command needs confirmation that was not given (`--yes` missing).
17    ConfirmationRequired = 2,
18    /// No credentials, expired token, or the profile could not be resolved.
19    Auth = 3,
20    /// The addressed entity does not exist or is not visible to this profile.
21    NotFound = 4,
22    /// The API refused the request (permissions, validation, rate limit).
23    ApiRejected = 5,
24    /// Recognised command that this build does not implement yet.
25    NotImplemented = 64,
26}
27
28impl From<ExitCode> for std::process::ExitCode {
29    fn from(code: ExitCode) -> Self {
30        Self::from(code as u8)
31    }
32}