commit-wizard 0.0.4

A lightweight CLI assistant for Conventional Commits, semantic versioning, and changelog automation.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! Turns an engine error into what the user sees: the report printed on stderr and the process exit status (see `engine::error` for the code ranges).

use std::process::ExitCode;

use crate::engine::Error;

pub type CoreResult<T> = Result<T, Error>;

pub fn report_error(err: &Error) {
    eprintln!("{}: {}", err.code.id(), err.message);
    for (key, value) in &err.context {
        eprintln!("  {key}: {value}");
    }
}

pub fn exit_code(err: &Error) -> ExitCode {
    ExitCode::from(err.exit_code() as u8)
}