pub fn exit_code(
report: &CheckReport,
policy: &FailOnPolicy,
had_execution_error: ExecutionOutcome,
) -> i32Expand description
Computes the process exit code for a completed check run.
A real policy violation (T021) always reports as 1, even when had_execution_error is
also set: a genuine --fail-on hit is the more actionable signal, and an unrelated
registry/parse error elsewhere in the run must not hide it behind a less specific 2
(spec 062 review S3 — the original precedence order lost this signal, e.g. one malformed
manifest anywhere in a monorepo turning a real --fail-on vulnerable hit from 1 into
2). had_execution_error only takes precedence over an otherwise-clean policy result:
a run that could not reach a registry it needed, or failed to parse a manifest, produced
an incomplete report, so its exit code must never claim a clean 0, even when nothing
already-resolved happened to violate policy.
§Examples
use deps_cli::exit::{EXIT_CLEAN, EXIT_EXECUTION_ERROR, EXIT_POLICY_VIOLATION, ExecutionOutcome, exit_code};
use deps_cli::report::{CheckReport, FailOnPolicy};
let clean = CheckReport::default();
let policy = FailOnPolicy::default_categories();
assert_eq!(exit_code(&clean, &policy, ExecutionOutcome::Clean), EXIT_CLEAN);
assert_eq!(exit_code(&clean, &policy, ExecutionOutcome::Failed), EXIT_EXECUTION_ERROR);