1 /// Represents the color preferences for program output
2 #[derive(Debug, Copy, Clone, Eq, PartialEq)]
3 pub enum ColorChoice {
4     /// Enables colored output only when the output is going to a terminal or TTY.
5     ///
6     /// **NOTE:** This is the default behavior of `clap`.
7     ///
8     /// # Platform Specific
9     ///
10     /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms).
11     ///
12     /// # Examples
13     ///
14     #[cfg_attr(not(feature = "color"), doc = " ```ignore")]
15     #[cfg_attr(feature = "color", doc = " ```no_run")]
16     /// # use clap::{App, ColorChoice};
17     /// App::new("myprog")
18     ///     .color(ColorChoice::Auto)
19     ///     .get_matches();
20     /// ```
21     Auto,
22 
23     /// Enables colored output regardless of whether or not the output is going to a terminal/TTY.
24     ///
25     /// # Platform Specific
26     ///
27     /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms).
28     ///
29     /// # Examples
30     ///
31     #[cfg_attr(not(feature = "color"), doc = " ```ignore")]
32     #[cfg_attr(feature = "color", doc = " ```no_run")]
33     /// # use clap::{App, ColorChoice};
34     /// App::new("myprog")
35     ///     .color(ColorChoice::Always)
36     ///     .get_matches();
37     /// ```
38     Always,
39 
40     /// Disables colored output no matter if the output is going to a terminal/TTY, or not.
41     ///
42     /// # Platform Specific
43     ///
44     /// This setting only applies to Unix, Linux, and macOS (i.e. non-Windows platforms)
45     ///
46     /// # Examples
47     ///
48     #[cfg_attr(not(feature = "color"), doc = " ```ignore")]
49     #[cfg_attr(feature = "color", doc = " ```no_run")]
50     /// # use clap::{App, ColorChoice};
51     /// App::new("myprog")
52     ///     .color(ColorChoice::Never)
53     ///     .get_matches();
54     /// ```
55     Never,
56 }
57 
58 impl Default for ColorChoice {
default() -> Self59     fn default() -> Self {
60         Self::Auto
61     }
62 }
63 
64 #[cfg(feature = "color")]
65 pub(crate) use termcolor::Color;
66 
67 #[cfg(not(feature = "color"))]
68 #[derive(Debug)]
69 pub(crate) enum Color {
70     Green,
71     Yellow,
72     Red,
73 }
74