cargo-mend 0.16.1

Opinionated visibility auditing for Rust crates and workspaces
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use super::ColorMode;
use crate::reporting::constants::ANSI_BOLD_BLUE;
use crate::reporting::constants::ANSI_DIM;

pub(super) fn dim(text: &str, color_mode: ColorMode) -> String { paint(text, ANSI_DIM, color_mode) }

pub(super) fn blue_bold(text: &str, color_mode: ColorMode) -> String {
    paint(text, ANSI_BOLD_BLUE, color_mode)
}

pub(super) fn paint(text: &str, code: &str, color_mode: ColorMode) -> String {
    match color_mode {
        ColorMode::Enabled => format!("\x1b[{code}m{text}\x1b[0m"),
        ColorMode::Disabled => text.to_string(),
    }
}