File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 1
- use std:: io:: IsTerminal ;
1
+ use std:: { env , io:: IsTerminal } ;
2
2
3
3
use owo_colors:: Style ;
4
4
@@ -21,8 +21,16 @@ pub struct GraphicalTheme {
21
21
pub styles : ThemeStyles ,
22
22
}
23
23
24
+ fn force_color ( ) -> bool {
25
+ // Assume CI can always print colors.
26
+ env:: var ( "CI" ) . is_ok ( ) || env:: var ( "FORCE_COLOR" ) . is_ok_and ( |env| env != "0" )
27
+ }
28
+
24
29
impl Default for GraphicalTheme {
25
30
fn default ( ) -> Self {
31
+ if force_color ( ) {
32
+ return Self :: unicode ( ) ;
33
+ }
26
34
match std:: env:: var ( "NO_COLOR" ) {
27
35
_ if !std:: io:: stdout ( ) . is_terminal ( ) || !std:: io:: stderr ( ) . is_terminal ( ) => {
28
36
Self :: none ( )
@@ -35,6 +43,9 @@ impl Default for GraphicalTheme {
35
43
36
44
impl GraphicalTheme {
37
45
pub fn new ( is_terminal : bool ) -> Self {
46
+ if force_color ( ) {
47
+ return Self :: unicode ( ) ;
48
+ }
38
49
match std:: env:: var ( "NO_COLOR" ) {
39
50
_ if !is_terminal => Self :: none ( ) ,
40
51
Ok ( string) if string != "0" => Self :: unicode_nocolor ( ) ,
You can’t perform that action at this time.
0 commit comments