diff --git a/src/operations.rs b/src/operations.rs index 9fd7f1b8..5c6de31b 100644 --- a/src/operations.rs +++ b/src/operations.rs @@ -17,7 +17,7 @@ use crate::utils::is_valid_julia_path; use anyhow::{anyhow, bail, Context, Error, Result}; use bstr::ByteSlice; use bstr::ByteVec; -use console::style; +use console::{colors_enabled, style}; #[cfg(not(target_os = "freebsd"))] use flate2::read::GzDecoder; use indicatif::{ProgressBar, ProgressStyle}; @@ -92,6 +92,19 @@ where Ok(()) } +fn bar_style() -> ProgressStyle { + let pchars = if colors_enabled() { + "━╸━" + } else { + "━╸ " + }; + + ProgressStyle::default_bar() + .template("{prefix:.cyan.bold}: {bar:.cyan/black.bright} {bytes}/{total_bytes} eta: {eta}") + .unwrap() + .progress_chars(pchars) +} + #[cfg(not(windows))] pub fn download_extract_sans_parent( url: &str, @@ -109,13 +122,8 @@ pub fn download_extract_sans_parent( None => ProgressBar::new_spinner(), }; - pb.set_prefix(" Downloading:"); - pb.set_style( - ProgressStyle::default_bar() - .template("{prefix:.cyan.bold} [{bar}] {bytes}/{total_bytes} eta: {eta}") - .unwrap() - .progress_chars("=> "), - ); + pb.set_prefix(" Downloading"); + pb.set_style(bar_style()); let last_modified = match response .headers() @@ -209,13 +217,8 @@ pub fn download_extract_sans_parent( ProgressBar::new_spinner() }; - pb.set_prefix(" Downloading:"); - pb.set_style( - ProgressStyle::default_bar() - .template("{prefix:.cyan.bold} [{bar}] {bytes}/{total_bytes} eta: {eta}") - .unwrap() - .progress_chars("=> "), - ); + pb.set_prefix(" Downloading"); + pb.set_style(bar_style()); let response_with_pb = pb.wrap_read(DataReaderWrap(reader));