File tree 3 files changed +8
-2
lines changed
3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 4
4
5
5
## Bugfixes
6
6
7
+ - Fix ` NO_COLOR ` support, see #2767 (@acuteenvy )
8
+
7
9
## Other
8
10
9
11
- Upgrade to Rust 2021 edition #2748 (@cyqsimon )
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ fn is_truecolor_terminal() -> bool {
29
29
. unwrap_or ( false )
30
30
}
31
31
32
+ pub fn env_no_color ( ) -> bool {
33
+ env:: var_os ( "NO_COLOR" ) . is_some_and ( |x| !x. is_empty ( ) )
34
+ }
35
+
32
36
pub struct App {
33
37
pub matches : ArgMatches ,
34
38
interactive_output : bool ,
@@ -207,7 +211,7 @@ impl App {
207
211
|| match self . matches . get_one :: < String > ( "color" ) . map ( |s| s. as_str ( ) ) {
208
212
Some ( "always" ) => true ,
209
213
Some ( "never" ) => false ,
210
- Some ( "auto" ) => env :: var_os ( "NO_COLOR" ) . is_none ( ) && self . interactive_output ,
214
+ Some ( "auto" ) => ! env_no_color ( ) && self . interactive_output ,
211
215
_ => unreachable ! ( "other values for --color are not allowed" ) ,
212
216
} ,
213
217
paging_mode,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ static VERSION: Lazy<String> = Lazy::new(|| {
19
19
} ) ;
20
20
21
21
pub fn build_app ( interactive_output : bool ) -> Command {
22
- let color_when = if interactive_output && env :: var_os ( "NO_COLOR" ) . is_none ( ) {
22
+ let color_when = if interactive_output && ! crate :: app :: env_no_color ( ) {
23
23
ColorChoice :: Auto
24
24
} else {
25
25
ColorChoice :: Never
You can’t perform that action at this time.
0 commit comments