From 2d7e0a2fbf1c8a4187e2bf3fdcd592631ab273a0 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Fri, 26 May 2023 17:40:27 +0200 Subject: added full progress? cargo fmt --- src/commands/download.rs | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) (limited to 'src/commands/download.rs') diff --git a/src/commands/download.rs b/src/commands/download.rs index 7aa0156..dd00ffb 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs @@ -1,7 +1,5 @@ +use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; -use indicatif::{MultiProgress, ProgressStyle, ProgressBar}; - -use crate::{STYLE_BAR_POS, PROGRESS_CHARS}; use crate::{config::Cfg, List}; use crate::{ db::userlist_get_all_current_versions_with_mods, @@ -11,12 +9,21 @@ use crate::{ }, modrinth::get_raw_versions, }; - -pub async fn download(config: &Cfg, liststack: Vec, clean: bool, delete_old: bool) -> MLE<()> { - +use crate::{PROGRESS_CHARS, STYLE_BAR_POS}; + +pub async fn download( + config: &Cfg, + liststack: Vec, + clean: bool, + delete_old: bool, +) -> MLE<()> { let mp = MultiProgress::new(); let download_p = mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); - download_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); + download_p.set_style( + ProgressStyle::with_template(STYLE_BAR_POS) + .unwrap() + .progress_chars(PROGRESS_CHARS), + ); for current_list in liststack { download_p.set_message(format!("Download in {}", current_list.id)); @@ -67,17 +74,27 @@ pub async fn download(config: &Cfg, liststack: Vec, clean: bool, delete_ol ) .await?; } else { - download_p.println(format!("There are no new versions to download for {}", current_list.id)); + download_p.println(format!( + "There are no new versions to download for {}", + current_list.id + )); } if !to_disable.is_empty() { - let d_p = mp.insert_before(&download_p, ProgressBar::new(to_disable.len().try_into().unwrap())); - d_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); + let d_p = mp.insert_before( + &download_p, + ProgressBar::new(to_disable.len().try_into().unwrap()), + ); + d_p.set_style( + ProgressStyle::with_template(STYLE_BAR_POS) + .unwrap() + .progress_chars(PROGRESS_CHARS), + ); for ver in to_disable { if delete_old { d_p.set_message(format!("Delete version {}", ver.1)); d_p.inc(1); - delete_version(current_list.clone(), ver.1)?; + delete_version(¤t_list, ver.1)?; } else { d_p.set_message(format!("Disable version {}", ver.1)); d_p.inc(1); -- cgit v1.2.3