diff options
author | fxqnlr <[email protected]> | 2023-05-26 17:40:27 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2023-05-26 17:40:27 +0200 |
commit | 2d7e0a2fbf1c8a4187e2bf3fdcd592631ab273a0 (patch) | |
tree | cc8f3522670245775e4be7ac2a1e2ad4fd818c8f /src/commands/download.rs | |
parent | d8554e30029bf43dccce72e982784cd01857b0c4 (diff) | |
download | modlist-2d7e0a2fbf1c8a4187e2bf3fdcd592631ab273a0.tar modlist-2d7e0a2fbf1c8a4187e2bf3fdcd592631ab273a0.tar.gz modlist-2d7e0a2fbf1c8a4187e2bf3fdcd592631ab273a0.zip |
added full progress? cargo fmt
Diffstat (limited to 'src/commands/download.rs')
-rw-r--r-- | src/commands/download.rs | 39 |
1 files changed, 28 insertions, 11 deletions
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 @@ | |||
1 | use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; | ||
1 | 2 | ||
2 | use indicatif::{MultiProgress, ProgressStyle, ProgressBar}; | ||
3 | |||
4 | use crate::{STYLE_BAR_POS, PROGRESS_CHARS}; | ||
5 | use crate::{config::Cfg, List}; | 3 | use crate::{config::Cfg, List}; |
6 | use crate::{ | 4 | use crate::{ |
7 | db::userlist_get_all_current_versions_with_mods, | 5 | db::userlist_get_all_current_versions_with_mods, |
@@ -11,12 +9,21 @@ use crate::{ | |||
11 | }, | 9 | }, |
12 | modrinth::get_raw_versions, | 10 | modrinth::get_raw_versions, |
13 | }; | 11 | }; |
14 | 12 | use crate::{PROGRESS_CHARS, STYLE_BAR_POS}; | |
15 | pub async fn download(config: &Cfg, liststack: Vec<List>, clean: bool, delete_old: bool) -> MLE<()> { | 13 | |
16 | 14 | pub async fn download( | |
15 | config: &Cfg, | ||
16 | liststack: Vec<List>, | ||
17 | clean: bool, | ||
18 | delete_old: bool, | ||
19 | ) -> MLE<()> { | ||
17 | let mp = MultiProgress::new(); | 20 | let mp = MultiProgress::new(); |
18 | let download_p = mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); | 21 | let download_p = mp.add(ProgressBar::new(liststack.len().try_into().unwrap())); |
19 | download_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); | 22 | download_p.set_style( |
23 | ProgressStyle::with_template(STYLE_BAR_POS) | ||
24 | .unwrap() | ||
25 | .progress_chars(PROGRESS_CHARS), | ||
26 | ); | ||
20 | 27 | ||
21 | for current_list in liststack { | 28 | for current_list in liststack { |
22 | download_p.set_message(format!("Download in {}", current_list.id)); | 29 | download_p.set_message(format!("Download in {}", current_list.id)); |
@@ -67,17 +74,27 @@ pub async fn download(config: &Cfg, liststack: Vec<List>, clean: bool, delete_ol | |||
67 | ) | 74 | ) |
68 | .await?; | 75 | .await?; |
69 | } else { | 76 | } else { |
70 | download_p.println(format!("There are no new versions to download for {}", current_list.id)); | 77 | download_p.println(format!( |
78 | "There are no new versions to download for {}", | ||
79 | current_list.id | ||
80 | )); | ||
71 | } | 81 | } |
72 | 82 | ||
73 | if !to_disable.is_empty() { | 83 | if !to_disable.is_empty() { |
74 | let d_p = mp.insert_before(&download_p, ProgressBar::new(to_disable.len().try_into().unwrap())); | 84 | let d_p = mp.insert_before( |
75 | d_p.set_style(ProgressStyle::with_template(STYLE_BAR_POS).unwrap().progress_chars(PROGRESS_CHARS)); | 85 | &download_p, |
86 | ProgressBar::new(to_disable.len().try_into().unwrap()), | ||
87 | ); | ||
88 | d_p.set_style( | ||
89 | ProgressStyle::with_template(STYLE_BAR_POS) | ||
90 | .unwrap() | ||
91 | .progress_chars(PROGRESS_CHARS), | ||
92 | ); | ||
76 | for ver in to_disable { | 93 | for ver in to_disable { |
77 | if delete_old { | 94 | if delete_old { |
78 | d_p.set_message(format!("Delete version {}", ver.1)); | 95 | d_p.set_message(format!("Delete version {}", ver.1)); |
79 | d_p.inc(1); | 96 | d_p.inc(1); |
80 | delete_version(current_list.clone(), ver.1)?; | 97 | delete_version(¤t_list, ver.1)?; |
81 | } else { | 98 | } else { |
82 | d_p.set_message(format!("Disable version {}", ver.1)); | 99 | d_p.set_message(format!("Disable version {}", ver.1)); |
83 | d_p.inc(1); | 100 | d_p.inc(1); |