File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ pub struct GlobalArgs {
179179 conflicts_with = "no_color" ,
180180 value_name = "COLOR_CHOICE"
181181 ) ]
182- pub color : ColorChoice ,
182+ pub color : Option < ColorChoice > ,
183183
184184 /// Whether to load TLS certificates from the platform's native certificate store.
185185 ///
Original file line number Diff line number Diff line change @@ -74,11 +74,14 @@ impl GlobalSettings {
7474 Self {
7575 quiet : args. quiet ,
7676 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 ( )
8183 {
84+ // If the `NO_COLOR` is set, disable color output.
8285 ColorChoice :: Never
8386 } else if std:: env:: var_os ( EnvVars :: FORCE_COLOR )
8487 . filter ( |v| !v. is_empty ( ) )
@@ -87,9 +90,10 @@ impl GlobalSettings {
8790 . filter ( |v| !v. is_empty ( ) )
8891 . is_some ( )
8992 {
93+ // If `FORCE_COLOR` or `CLICOLOR_FORCE` is set, always enable color output.
9094 ColorChoice :: Always
9195 } else {
92- args . color
96+ ColorChoice :: Auto
9397 } ,
9498 native_tls : flag ( args. native_tls , args. no_native_tls )
9599 . combine ( workspace. and_then ( |workspace| workspace. globals . native_tls ) )
You can’t perform that action at this time.
0 commit comments