@@ -15,7 +15,7 @@ use crate::utils::is_valid_julia_path;
15
15
use anyhow:: { anyhow, bail, Context , Result } ;
16
16
use bstr:: ByteSlice ;
17
17
use bstr:: ByteVec ;
18
- use console:: style;
18
+ use console:: { colors_enabled , style} ;
19
19
#[ cfg( not( target_os = "freebsd" ) ) ]
20
20
use flate2:: read:: GzDecoder ;
21
21
use indicatif:: { ProgressBar , ProgressStyle } ;
88
88
Ok ( ( ) )
89
89
}
90
90
91
+ fn bar_style ( ) -> ProgressStyle {
92
+ let pchars = if colors_enabled ( ) {
93
+ "━╸━"
94
+ } else {
95
+ "━╸ "
96
+ } ;
97
+
98
+ ProgressStyle :: default_bar ( )
99
+ . template ( "{prefix:.cyan.bold}: {bar:.cyan/black.bright} {bytes}/{total_bytes} eta: {eta}" )
100
+ . unwrap ( )
101
+ . progress_chars ( pchars)
102
+ }
103
+
91
104
#[ cfg( not( windows) ) ]
92
105
pub fn download_extract_sans_parent (
93
106
url : & str ,
@@ -106,14 +119,7 @@ pub fn download_extract_sans_parent(
106
119
} ;
107
120
108
121
pb. set_prefix ( " Downloading" ) ;
109
- pb. set_style (
110
- ProgressStyle :: default_bar ( )
111
- . template (
112
- "{prefix:.cyan.bold}: {bar:.cyan/black.bright} {bytes}/{total_bytes} eta: {eta}" ,
113
- )
114
- . unwrap ( )
115
- . progress_chars ( "━╸━" ) ,
116
- ) ;
122
+ pb. set_style ( bar_style ( ) ) ;
117
123
118
124
let last_modified = match response
119
125
. headers ( )
@@ -207,12 +213,7 @@ pub fn download_extract_sans_parent(
207
213
} ;
208
214
209
215
pb. set_prefix ( " Downloading" ) ;
210
- pb. set_style (
211
- ProgressStyle :: default_bar ( )
212
- . template ( "{prefix:.cyan.bold}: {bar:.cyan/white} {bytes}/{total_bytes} eta: {eta}" )
213
- . unwrap ( )
214
- . progress_chars ( "━╸━" ) ,
215
- ) ;
216
+ pb. set_style ( bar_style ( ) ) ;
216
217
217
218
let response_with_pb = pb. wrap_read ( DataReaderWrap ( reader) ) ;
218
219
0 commit comments