File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 44
55## Bugfixes
66
7+ - Fix ` NO_COLOR ` support, see #2767 (@acuteenvy )
8+
79## Other
810
911- 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 {
2929 . unwrap_or ( false )
3030}
3131
32+ pub fn env_no_color ( ) -> bool {
33+ env:: var_os ( "NO_COLOR" ) . is_some_and ( |x| !x. is_empty ( ) )
34+ }
35+
3236pub struct App {
3337 pub matches : ArgMatches ,
3438 interactive_output : bool ,
@@ -207,7 +211,7 @@ impl App {
207211 || match self . matches . get_one :: < String > ( "color" ) . map ( |s| s. as_str ( ) ) {
208212 Some ( "always" ) => true ,
209213 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 ,
211215 _ => unreachable ! ( "other values for --color are not allowed" ) ,
212216 } ,
213217 paging_mode,
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ static VERSION: Lazy<String> = Lazy::new(|| {
1919} ) ;
2020
2121pub 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 ( ) {
2323 ColorChoice :: Auto
2424 } else {
2525 ColorChoice :: Never
You can’t perform that action at this time.
0 commit comments