kutil_cli/clap/colorize.rs
1use {anstream::ColorChoice, clap::*};
2
3//
4// Colorize
5//
6
7/// Colorization options for Clap.
8#[derive(Clone, Copy, Default, ValueEnum)]
9pub enum Colorize {
10 /// Colorize if supported.
11 #[default]
12 True,
13
14 /// Don't colorize.
15 False,
16
17 /// Colorize even if not supported.
18 Force,
19}
20
21impl Colorize {
22 /// Applies the colorization option globally.
23 pub fn initialize(&self) {
24 match self {
25 Self::True => {}
26 Self::False => ColorChoice::Never.write_global(),
27 Self::Force => ColorChoice::Always.write_global(),
28 }
29 }
30}