Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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,
Expand All @@ -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()
Expand Down Expand Up @@ -208,13 +216,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));

Expand Down
Loading