Skip to content

Commit

Permalink
When downloading, pad the file size on the left.
Browse files Browse the repository at this point in the history
Also pad the mod name when upgrading to the largest one, and clamp to between 20-50
  • Loading branch information
theRookieCoder committed Feb 7, 2024
1 parent 3d23ec0 commit 8449195
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ pub async fn download(
.lock()
.expect("Mutex poisoned")
.println(format!(
"{} Downloaded {:7} {}",
"{} Downloaded {:>7} {}",
&*TICK,
Size::from_bytes(length)
.format()
Expand Down
11 changes: 9 additions & 2 deletions src/subcommands/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ pub async fn get_platform_downloadables(
.lock()
.expect("Mutex poisoned")
.enable_steady_tick(Duration::from_millis(100));
let pad_len = profile
.mods
.iter()
.map(|m| m.name.len())
.max()
.unwrap_or(20)
.clamp(20, 50);
for mod_ in &profile.mods {
let permit = semaphore.clone().acquire_owned().await?;
let to_download = to_download.clone();
Expand Down Expand Up @@ -119,7 +126,7 @@ pub async fn get_platform_downloadables(
match result {
Ok((downloadable, qf_flag)) => {
progress_bar.println(format!(
"{} {:43} {}",
"{} {:pad_len$} {}",
if qf_flag {
YELLOW_TICK.clone()
} else {
Expand Down Expand Up @@ -147,7 +154,7 @@ pub async fn get_platform_downloadables(
}
progress_bar.println(format!(
"{}",
format!("{CROSS} {:43} {err}", mod_.name).red()
format!("{CROSS} {:pad_len$} {err}", mod_.name).red()
));
Ok((true, false))
}
Expand Down

0 comments on commit 8449195

Please sign in to comment.