Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update progress bar style to match 1.12 progress bar #1066

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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