From d8554e30029bf43dccce72e982784cd01857b0c4 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 25 May 2023 22:48:54 +0200 Subject: added mod add progress --- src/commands/update.rs | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'src/commands/update.rs') diff --git a/src/commands/update.rs b/src/commands/update.rs index bde6896..194bbe5 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -9,7 +9,7 @@ use crate::{ error::{ErrorType, MLError, MLE}, files::{clean_list_dir, delete_version, disable_version, download_versions}, modrinth::{extract_current_version, versions, Version}, - List, PROGRESS_CHARS, STYLE_BAR_POS, + List, PROGRESS_CHARS, STYLE_BAR_POS, STYLE_OPERATION, }; pub async fn update( @@ -23,23 +23,21 @@ pub async fn update( let mp = MultiProgress::new(); let update_p = mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); - let bar_style = ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS); - update_p.set_style(bar_style.clone()); - update_p.set_message("Update"); + update_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); for current_list in liststack { + update_p.set_message(format!("Update {}", current_list.id)); + let list_p = mp.insert_before(&update_p, ProgressBar::new(2)); - list_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); - list_p.set_message(format!("Update {}", current_list.id)); + list_p.set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); + list_p.set_message("Update mods"); let mods = userlist_get_all_ids(config, ¤t_list.id)?; let list_u_p = mp.insert_before(&list_p, ProgressBar::new(mods.len().try_into().unwrap())); - list_u_p.set_style(bar_style.clone()); - list_u_p.set_message(format!("Update {}", current_list.id)); + list_u_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); let mut current_versions: Vec<(String, String)> = vec![]; - let mut updatestack: Vec = vec![]; for id in mods { @@ -84,7 +82,6 @@ pub async fn update( } list_u_p.finish_with_message(format!("Updated mods in {}", current_list.id)); - list_p.inc(1); if clean { list_p.set_message("Cleaning"); @@ -92,12 +89,12 @@ pub async fn update( }; if direct_download && !updatestack.is_empty() { - download_versions(current_list.clone(), config.clone(), updatestack, &mp, Some(&list_p)).await?; + download_versions(current_list.clone(), config.clone(), updatestack, &mp, &list_p).await?; //Disable old versions if !clean { let d_p = mp.insert_before(&list_p, ProgressBar::new(current_versions.len().try_into().unwrap())); - d_p.set_style(bar_style.clone()); + d_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); for ver in current_versions { if delete_old { d_p.set_message(format!("Delete version {}", ver.0)); @@ -119,14 +116,12 @@ pub async fn update( d_p.finish_with_message(del_msg); } }; - list_p.inc(1); list_p.finish_with_message(format!("Updated {}", current_list.id)); update_p.inc(1); } update_p.finish_with_message("Updated all lists"); - Ok(()) } -- cgit v1.2.3