diff options
author | fxqnlr <[email protected]> | 2024-09-04 12:03:13 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-09-04 12:03:13 +0200 |
commit | 29635b9e3833296b2c908914104ba7165d22d3d5 (patch) | |
tree | f89e2807e664327fa26191d6f017512a87ba38e7 /src/commands/update.rs | |
parent | 6a91d0a864f9edd9d9fe50ca89ccbce4fc98e043 (diff) | |
download | modlist-29635b9e3833296b2c908914104ba7165d22d3d5.tar modlist-29635b9e3833296b2c908914104ba7165d22d3d5.tar.gz modlist-29635b9e3833296b2c908914104ba7165d22d3d5.zip |
remove `# Panics` and fix clippy
Diffstat (limited to 'src/commands/update.rs')
-rw-r--r-- | src/commands/update.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/commands/update.rs b/src/commands/update.rs index d0b930d..c7965e3 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs | |||
@@ -18,7 +18,6 @@ use crate::{ | |||
18 | }; | 18 | }; |
19 | 19 | ||
20 | /// # Errors | 20 | /// # Errors |
21 | /// # Panics | ||
22 | pub async fn update( | 21 | pub async fn update( |
23 | config: &Cfg, | 22 | config: &Cfg, |
24 | liststack: Vec<List>, | 23 | liststack: Vec<List>, |
@@ -44,19 +43,26 @@ pub async fn update( | |||
44 | update_p.set_message(format!("Update {}", current_list.id)); | 43 | update_p.set_message(format!("Update {}", current_list.id)); |
45 | 44 | ||
46 | let list_p = mp.insert_before(&update_p, ProgressBar::new(2)); | 45 | let list_p = mp.insert_before(&update_p, ProgressBar::new(2)); |
47 | list_p | 46 | list_p.set_style( |
48 | .set_style(ProgressStyle::with_template(STYLE_OPERATION).unwrap()); | 47 | ProgressStyle::with_template(STYLE_OPERATION).map_err(|_| { |
48 | MLErr::new(EType::LibIndicatif, "template error") | ||
49 | })?, | ||
50 | ); | ||
49 | list_p.set_message("Update mods"); | 51 | list_p.set_message("Update mods"); |
50 | 52 | ||
51 | let mods = userlist_get_all_ids(config, ¤t_list.id)?; | 53 | let mods = userlist_get_all_ids(config, ¤t_list.id)?; |
52 | 54 | ||
53 | let list_u_p = mp.insert_before( | 55 | let list_u_p = mp.insert_before( |
54 | &list_p, | 56 | &list_p, |
55 | ProgressBar::new(mods.len().try_into().unwrap()), | 57 | ProgressBar::new( |
58 | mods.len() | ||
59 | .try_into() | ||
60 | .map_err(|_| MLErr::new(EType::Other, "ListStackLen"))?, | ||
61 | ), | ||
56 | ); | 62 | ); |
57 | list_u_p.set_style( | 63 | list_u_p.set_style( |
58 | ProgressStyle::with_template(STYLE_BAR_POS) | 64 | ProgressStyle::with_template(STYLE_BAR_POS) |
59 | .unwrap() | 65 | .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))? |
60 | .progress_chars(PROGRESS_CHARS), | 66 | .progress_chars(PROGRESS_CHARS), |
61 | ); | 67 | ); |
62 | 68 | ||
@@ -129,12 +135,12 @@ pub async fn update( | |||
129 | let d_p = mp.insert_before( | 135 | let d_p = mp.insert_before( |
130 | &list_p, | 136 | &list_p, |
131 | ProgressBar::new( | 137 | ProgressBar::new( |
132 | current_versions.len().try_into().unwrap(), | 138 | current_versions.len().try_into().map_err(|_| MLErr::new(EType::Other, "ListStackLen"))?, |
133 | ), | 139 | ), |
134 | ); | 140 | ); |
135 | d_p.set_style( | 141 | d_p.set_style( |
136 | ProgressStyle::with_template(STYLE_BAR_POS) | 142 | ProgressStyle::with_template(STYLE_BAR_POS) |
137 | .unwrap() | 143 | .map_err(|_| MLErr::new(EType::LibIndicatif, "template error"))? |
138 | .progress_chars(PROGRESS_CHARS), | 144 | .progress_chars(PROGRESS_CHARS), |
139 | ); | 145 | ); |
140 | for ver in current_versions { | 146 | for ver in current_versions { |
@@ -175,7 +181,7 @@ async fn specific_update( | |||
175 | progress: &ProgressBar, | 181 | progress: &ProgressBar, |
176 | ) -> MLE<Version> { | 182 | ) -> MLE<Version> { |
177 | let applicable_versions = | 183 | let applicable_versions = |
178 | versions(&config.apis.modrinth, String::from(id), list.clone()).await; | 184 | versions(&config.apis.modrinth, String::from(id), list.clone()).await?; |
179 | 185 | ||
180 | let mut versions: Vec<String> = vec![]; | 186 | let mut versions: Vec<String> = vec![]; |
181 | 187 | ||