Skip to main content

resolve_exit_code

Function resolve_exit_code 

Source
pub fn resolve_exit_code(result: Result<()>) -> i32
Expand description

Maps a run / run_with_args result to a sysexits-aligned exit code.

Side effect: on domain errors (and not signal/pipe), prints the human or JSON error envelope to stderr via output (same contract as the binary).

Prefer this from main so exit policy stays in the library (G-IO-11).

Recovers errors::SshCliError and bare crate::domain::DomainError that bubbled through anyhow without the product wrapper (R-04 / R-14).

ยงExamples

use ssh_cli::{errors::exit_codes, resolve_exit_code};

assert_eq!(resolve_exit_code(Ok(())), exit_codes::EX_OK);