From 8449195cc72bb35c02263a27e693dc9aca29cf71 Mon Sep 17 00:00:00 2001 From: Ilesh Thiada Date: Wed, 7 Feb 2024 18:58:33 +0530 Subject: [PATCH] When downloading, pad the file size on the left. Also pad the mod name when upgrading to the largest one, and clamp to between 20-50 --- src/download.rs | 2 +- src/subcommands/upgrade.rs | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/download.rs b/src/download.rs index 75e3b3d..728be9c 100644 --- a/src/download.rs +++ b/src/download.rs @@ -141,7 +141,7 @@ pub async fn download( .lock() .expect("Mutex poisoned") .println(format!( - "{} Downloaded {:7} {}", + "{} Downloaded {:>7} {}", &*TICK, Size::from_bytes(length) .format() diff --git a/src/subcommands/upgrade.rs b/src/subcommands/upgrade.rs index 7715270..971136e 100644 --- a/src/subcommands/upgrade.rs +++ b/src/subcommands/upgrade.rs @@ -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(); @@ -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 { @@ -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)) }