@@ -15,7 +15,7 @@ use crate::utils::is_valid_julia_path;
1515use anyhow:: { anyhow, bail, Context , Result } ;
1616use bstr:: ByteSlice ;
1717use bstr:: ByteVec ;
18- use console:: style;
18+ use console:: { colors_enabled , style} ;
1919#[ cfg( not( target_os = "freebsd" ) ) ]
2020use flate2:: read:: GzDecoder ;
2121use indicatif:: { ProgressBar , ProgressStyle } ;
8888 Ok ( ( ) )
8989}
9090
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+
91104#[ cfg( not( windows) ) ]
92105pub fn download_extract_sans_parent (
93106 url : & str ,
@@ -106,14 +119,7 @@ pub fn download_extract_sans_parent(
106119 } ;
107120
108121 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 ( ) ) ;
117123
118124 let last_modified = match response
119125 . headers ( )
@@ -207,12 +213,7 @@ pub fn download_extract_sans_parent(
207213 } ;
208214
209215 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 ( ) ) ;
216217
217218 let response_with_pb = pb. wrap_read ( DataReaderWrap ( reader) ) ;
218219
0 commit comments