exec_diff/color.rs
1/// Set color mode.
2#[derive(Debug, Clone, Copy, PartialEq, Eq)]
3pub enum Color {
4 /// Don't pass the `--color` option.
5 /// Allow the `diff` command to decide for itself
6 Auto,
7 /// Pass `--color=always` option.
8 /// Force the `diff` command to always show color.
9 Always,
10 /// Pass `--color=never` option.
11 /// Prevent the `diff` command from showing color.
12 Never,
13}
14
15impl Color {
16 /// Convert [`Color`] to CLI flag.
17 pub const fn as_flag(&self) -> Option<&'static str> {
18 match self {
19 Color::Auto => None,
20 Color::Always => Some("--color=always"),
21 Color::Never => Some("--color=never"),
22 }
23 }
24}