1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/// Set color mode.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Color {
    /// Don't pass the `--color` option.
    /// Allow the `diff` command to decide for itself
    Auto,
    /// Pass `--color=always` option.
    /// Force the `diff` command to always show color.
    Always,
    /// Pass `--color=never` option.
    /// Prevent the `diff` command from showing color.
    Never,
}

impl Color {
    /// Convert [`Color`] to CLI flag.
    pub const fn as_flag(&self) -> Option<&'static str> {
        match self {
            Color::Auto => None,
            Color::Always => Some("--color=always"),
            Color::Never => Some("--color=never"),
        }
    }
}