Expand description
A small carrier for “this command finished, but report a specific
non-zero exit code” – the equivalent of Go’s cli.Exit("", code)
(urfave/cli/v3’s cli.ExitCoder).
Go’s cli.Exit constructs a special error value that the cli
framework inspects at the top level to pick a process exit code,
without printing anything extra (the command has already reported
whatever went wrong). This crate’s commands return anyhow::Result,
so CliExit plays the same role: a command’s business logic
returns Err(CliExit::new(code).into()) instead of calling
std::process::exit directly (which would make it untestable –
every in-process test calling that code path would kill the whole
test binary), and exit_for at the real process boundary
(main/commands::dispatch) inspects the final error to translate
it into the matching process exit code.
Structs§
- CliExit
- Port of
cli.Exit’sExitCoder: an error carrying a specific process exit code rather than a message to print (the command already reported whatever went wrong on its own streams).