@@ -17,7 +17,7 @@ use crate::utils::is_valid_julia_path;
1717use anyhow:: { anyhow, bail, Context , Result } ;
1818use bstr:: ByteSlice ;
1919use bstr:: ByteVec ;
20- use console:: style;
20+ use console:: { colors_enabled , style} ;
2121#[ cfg( not( target_os = "freebsd" ) ) ]
2222use flate2:: read:: GzDecoder ;
2323use indicatif:: { ProgressBar , ProgressStyle } ;
9292 Ok ( ( ) )
9393}
9494
95+ fn bar_style ( ) -> ProgressStyle {
96+ let pchars = if colors_enabled ( ) {
97+ "━╸━"
98+ } else {
99+ "━╸ "
100+ } ;
101+
102+ ProgressStyle :: default_bar ( )
103+ . template ( "{prefix:.cyan.bold}: {bar:.cyan/black.bright} {bytes}/{total_bytes} eta: {eta}" )
104+ . unwrap ( )
105+ . progress_chars ( pchars)
106+ }
107+
95108#[ cfg( not( windows) ) ]
96109pub fn download_extract_sans_parent (
97110 url : & str ,
@@ -110,14 +123,7 @@ pub fn download_extract_sans_parent(
110123 } ;
111124
112125 pb. set_prefix ( " Downloading" ) ;
113- pb. set_style (
114- ProgressStyle :: default_bar ( )
115- . template (
116- "{prefix:.cyan.bold}: {bar:.cyan/black.bright} {bytes}/{total_bytes} eta: {eta}" ,
117- )
118- . unwrap ( )
119- . progress_chars ( "━╸━" ) ,
120- ) ;
126+ pb. set_style ( bar_style ( ) ) ;
121127
122128 let last_modified = match response
123129 . headers ( )
@@ -211,12 +217,7 @@ pub fn download_extract_sans_parent(
211217 } ;
212218
213219 pb. set_prefix ( " Downloading" ) ;
214- pb. set_style (
215- ProgressStyle :: default_bar ( )
216- . template ( "{prefix:.cyan.bold}: {bar:.cyan/white} {bytes}/{total_bytes} eta: {eta}" )
217- . unwrap ( )
218- . progress_chars ( "━╸━" ) ,
219- ) ;
220+ pb. set_style ( bar_style ( ) ) ;
220221
221222 let response_with_pb = pb. wrap_read ( DataReaderWrap ( reader) ) ;
222223
0 commit comments