File tree 2 files changed +10
-6
lines changed
2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ pub struct GlobalArgs {
179
179
conflicts_with = "no_color" ,
180
180
value_name = "COLOR_CHOICE"
181
181
) ]
182
- pub color : ColorChoice ,
182
+ pub color : Option < ColorChoice > ,
183
183
184
184
/// Whether to load TLS certificates from the platform's native certificate store.
185
185
///
Original file line number Diff line number Diff line change @@ -74,11 +74,14 @@ impl GlobalSettings {
74
74
Self {
75
75
quiet : args. quiet ,
76
76
verbose : args. verbose ,
77
- color : if args. no_color
78
- || std:: env:: var_os ( EnvVars :: NO_COLOR )
79
- . filter ( |v| !v. is_empty ( ) )
80
- . is_some ( )
77
+ color : if let Some ( color_choice) = args. color {
78
+ // If `--color` is passed explicitly, use its value.
79
+ color_choice
80
+ } else if std:: env:: var_os ( EnvVars :: NO_COLOR )
81
+ . filter ( |v| !v. is_empty ( ) )
82
+ . is_some ( )
81
83
{
84
+ // If the `NO_COLOR` is set, disable color output.
82
85
ColorChoice :: Never
83
86
} else if std:: env:: var_os ( EnvVars :: FORCE_COLOR )
84
87
. filter ( |v| !v. is_empty ( ) )
@@ -87,9 +90,10 @@ impl GlobalSettings {
87
90
. filter ( |v| !v. is_empty ( ) )
88
91
. is_some ( )
89
92
{
93
+ // If `FORCE_COLOR` or `CLICOLOR_FORCE` is set, always enable color output.
90
94
ColorChoice :: Always
91
95
} else {
92
- args . color
96
+ ColorChoice :: Auto
93
97
} ,
94
98
native_tls : flag ( args. native_tls , args. no_native_tls )
95
99
. combine ( workspace. and_then ( |workspace| workspace. globals . native_tls ) )
You can’t perform that action at this time.
0 commit comments