diff options
author | fxqnlr <[email protected]> | 2023-05-25 17:23:52 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2023-05-25 17:23:52 +0200 |
commit | 48393b209396db9ddd44251b2bb445d3ad7533fb (patch) | |
tree | 264b459bacc0f6c62f26c3fd45c83ee9946babe2 /src/commands | |
parent | 529d52534c300aec4a6e3e9e08f9762a401f7086 (diff) | |
download | modlist-48393b209396db9ddd44251b2bb445d3ad7533fb.tar modlist-48393b209396db9ddd44251b2bb445d3ad7533fb.tar.gz modlist-48393b209396db9ddd44251b2bb445d3ad7533fb.zip |
changed a whole lot og references, fuck rust
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/download.rs | 6 | ||||
-rw-r--r-- | src/commands/io.rs | 34 | ||||
-rw-r--r-- | src/commands/list.rs | 33 | ||||
-rw-r--r-- | src/commands/modification.rs | 30 | ||||
-rw-r--r-- | src/commands/update.rs | 32 |
5 files changed, 66 insertions, 69 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs index 6831714..fea3f34 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs | |||
@@ -9,13 +9,13 @@ use crate::{ | |||
9 | modrinth::get_raw_versions, | 9 | modrinth::get_raw_versions, |
10 | }; | 10 | }; |
11 | 11 | ||
12 | pub async fn download(config: Cfg, liststack: Vec<List>, clean: bool, delete_old: bool) -> MLE<()> { | 12 | pub async fn download(config: &Cfg, liststack: Vec<List>, clean: bool, delete_old: bool) -> MLE<()> { |
13 | for current_list in liststack { | 13 | for current_list in liststack { |
14 | println!("Downloading current versions of mods in {}", current_list.id); | 14 | println!("Downloading current versions of mods in {}", current_list.id); |
15 | let downloaded_versions = get_downloaded_versions(current_list.clone())?; | 15 | let downloaded_versions = get_downloaded_versions(current_list.clone())?; |
16 | // println!("To download: {:#?}", downloaded_versions); | 16 | // println!("To download: {:#?}", downloaded_versions); |
17 | let current_version_ids = match userlist_get_all_current_versions_with_mods( | 17 | let current_version_ids = match userlist_get_all_current_versions_with_mods( |
18 | config.clone(), | 18 | config, |
19 | String::from(¤t_list.id), | 19 | String::from(¤t_list.id), |
20 | ) { | 20 | ) { |
21 | Ok(i) => Ok(i), | 21 | Ok(i) => Ok(i), |
@@ -66,7 +66,7 @@ pub async fn download(config: Cfg, liststack: Vec<List>, clean: bool, delete_old | |||
66 | // println!("Deleting version {} for mod {}", ver.1, ver.0); | 66 | // println!("Deleting version {} for mod {}", ver.1, ver.0); |
67 | delete_version(current_list.clone(), ver.1)?; | 67 | delete_version(current_list.clone(), ver.1)?; |
68 | } else { | 68 | } else { |
69 | disable_version(config.clone(), current_list.clone(), ver.1, ver.0)?; | 69 | disable_version(config, current_list.clone(), ver.1, ver.0)?; |
70 | }; | 70 | }; |
71 | } | 71 | } |
72 | } | 72 | } |
diff --git a/src/commands/io.rs b/src/commands/io.rs index 2a26f1d..43e642a 100644 --- a/src/commands/io.rs +++ b/src/commands/io.rs | |||
@@ -21,9 +21,9 @@ struct ExportVersion { | |||
21 | } | 21 | } |
22 | 22 | ||
23 | impl ExportVersion { | 23 | impl ExportVersion { |
24 | fn from(config: Cfg, list_id: &str, mod_id: &str) -> MLE<Self> { | 24 | fn from(config: &Cfg, list_id: &str, mod_id: &str) -> MLE<Self> { |
25 | Ok(Self { | 25 | Ok(Self { |
26 | version: userlist_get_current_version(config.clone(), list_id, mod_id)?, | 26 | version: userlist_get_current_version(config, list_id, mod_id)?, |
27 | set: userlist_get_set_version(config, list_id, mod_id)? | 27 | set: userlist_get_set_version(config, list_id, mod_id)? |
28 | }) | 28 | }) |
29 | } | 29 | } |
@@ -39,18 +39,18 @@ struct ExportList { | |||
39 | } | 39 | } |
40 | 40 | ||
41 | impl ExportList { | 41 | impl ExportList { |
42 | pub fn from(config: Cfg, list_id: String, download: bool) -> MLE<Self> { | 42 | pub fn from(config: &Cfg, list_id: String, download: bool) -> MLE<Self> { |
43 | let list = lists_get(config.clone(), String::from(&list_id))?; | 43 | let list = lists_get(config, String::from(&list_id))?; |
44 | 44 | ||
45 | let mut dl_folder = None; | 45 | let mut dl_folder = None; |
46 | if download { | 46 | if download { |
47 | dl_folder = Some(list.download_folder) | 47 | dl_folder = Some(list.download_folder) |
48 | }; | 48 | }; |
49 | 49 | ||
50 | let mods = userlist_get_all_ids(config.clone(), &list_id)?; | 50 | let mods = userlist_get_all_ids(config, &list_id)?; |
51 | let mut versions = vec![]; | 51 | let mut versions = vec![]; |
52 | for m in mods { | 52 | for m in mods { |
53 | versions.push(ExportVersion::from(config.clone(), &list_id, &m)?) | 53 | versions.push(ExportVersion::from(config, &list_id, &m)?) |
54 | } | 54 | } |
55 | 55 | ||
56 | Ok(Self { | 56 | Ok(Self { |
@@ -63,16 +63,16 @@ impl ExportList { | |||
63 | } | 63 | } |
64 | } | 64 | } |
65 | 65 | ||
66 | pub fn export(config: Cfg, list: Option<String>) -> MLE<()> { | 66 | pub fn export(config: &Cfg, list: Option<String>) -> MLE<()> { |
67 | let mut list_ids: Vec<String> = vec![]; | 67 | let mut list_ids: Vec<String> = vec![]; |
68 | if list.is_none() { | 68 | if list.is_none() { |
69 | list_ids = lists_get_all_ids(config.clone())?; | 69 | list_ids = lists_get_all_ids(config)?; |
70 | } else { | 70 | } else { |
71 | list_ids.push(lists_get(config.clone(), list.unwrap())?.id); | 71 | list_ids.push(lists_get(config, list.unwrap())?.id); |
72 | } | 72 | } |
73 | let mut lists: Vec<ExportList> = vec![]; | 73 | let mut lists: Vec<ExportList> = vec![]; |
74 | for list_id in list_ids { | 74 | for list_id in list_ids { |
75 | lists.push(ExportList::from(config.clone(), list_id, true)?); | 75 | lists.push(ExportList::from(config, list_id, true)?); |
76 | } | 76 | } |
77 | 77 | ||
78 | let toml = toml::to_string(&Export { lists })?; | 78 | let toml = toml::to_string(&Export { lists })?; |
@@ -85,7 +85,7 @@ pub fn export(config: Cfg, list: Option<String>) -> MLE<()> { | |||
85 | Ok(()) | 85 | Ok(()) |
86 | } | 86 | } |
87 | 87 | ||
88 | pub async fn import(config: Cfg, file_str: String, direct_download: bool) -> MLE<()> { | 88 | pub async fn import(config: &Cfg, file_str: String, direct_download: bool) -> MLE<()> { |
89 | let mut file = File::open(file_str)?; | 89 | let mut file = File::open(file_str)?; |
90 | let mut content = String::new(); | 90 | let mut content = String::new(); |
91 | file.read_to_string(&mut content)?; | 91 | file.read_to_string(&mut content)?; |
@@ -99,18 +99,18 @@ pub async fn import(config: Cfg, file_str: String, direct_download: bool) -> MLE | |||
99 | download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), | 99 | download_folder: exportlist.download_folder.ok_or("NO_DL").unwrap(), |
100 | }; | 100 | }; |
101 | lists_insert( | 101 | lists_insert( |
102 | config.clone(), | 102 | config, |
103 | list.id.clone(), | 103 | &list.id, |
104 | list.mc_version.clone(), | 104 | &list.mc_version, |
105 | list.modloader.clone(), | 105 | &list.modloader, |
106 | String::from(&list.download_folder), | 106 | &list.download_folder, |
107 | )?; | 107 | )?; |
108 | 108 | ||
109 | let mut ver_ids = vec![]; | 109 | let mut ver_ids = vec![]; |
110 | for id in exportlist.versions { | 110 | for id in exportlist.versions { |
111 | ver_ids.push(AddMod { id: IDSelector::VersionID(id.version), set_version: id.set} ); | 111 | ver_ids.push(AddMod { id: IDSelector::VersionID(id.version), set_version: id.set} ); |
112 | } | 112 | } |
113 | mod_add(config.clone(), ver_ids, list, direct_download).await?; | 113 | mod_add(config, ver_ids, list, direct_download).await?; |
114 | } | 114 | } |
115 | Ok(()) | 115 | Ok(()) |
116 | } | 116 | } |
diff --git a/src/commands/list.rs b/src/commands/list.rs index c07823b..95f9927 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs | |||
@@ -16,30 +16,31 @@ pub struct List { | |||
16 | pub download_folder: String, | 16 | pub download_folder: String, |
17 | } | 17 | } |
18 | 18 | ||
19 | pub fn get_current_list(config: Cfg) -> MLE<List> { | 19 | pub fn get_current_list(config: &Cfg) -> MLE<List> { |
20 | let id = config_get_current_list(config.clone())?; | 20 | let id = config_get_current_list(config)?; |
21 | lists_get(config, id) | 21 | lists_get(config, id) |
22 | } | 22 | } |
23 | 23 | ||
24 | pub fn list_add( | 24 | pub fn list_add( |
25 | config: Cfg, | 25 | config: &Cfg, |
26 | id: String, | 26 | id: &str, |
27 | mc_version: String, | 27 | mc_version: &str, |
28 | modloader: Modloader, | 28 | modloader: &Modloader, |
29 | directory: String, | 29 | directory: &str, |
30 | ) -> MLE<()> { | 30 | ) -> MLE<()> { |
31 | lists_insert(config, id, mc_version, modloader, directory) | 31 | lists_insert(config, id, mc_version, modloader, directory) |
32 | } | 32 | } |
33 | 33 | ||
34 | pub fn list_change(config: Cfg, id: String) -> MLE<()> { | 34 | pub fn list_change(config: &Cfg, id: String) -> MLE<()> { |
35 | if !lists_get_all_ids(config.clone())?.into_iter().any(|l| l == id) { | 35 | if !lists_get_all_ids(config)?.into_iter().any(|l| l == id) { |
36 | return Err(MLError::new(ErrorType::ArgumentError, "List not found")); | 36 | return Err(MLError::new(ErrorType::ArgumentError, "List not found")); |
37 | }; | 37 | }; |
38 | println!("Change default list to: {}", id); | 38 | println!("Change default list to: {}", id); |
39 | config_change_current_list(config, id) | 39 | config_change_current_list(config, id) |
40 | } | 40 | } |
41 | 41 | ||
42 | pub fn list_remove(config: Cfg, id: String) -> MLE<()> { | 42 | pub fn list_remove(config: &Cfg, id: String) -> MLE<()> { |
43 | //TODO add logging | ||
43 | lists_remove(config, id) | 44 | lists_remove(config, id) |
44 | } | 45 | } |
45 | 46 | ||
@@ -50,7 +51,7 @@ pub fn list_remove(config: Cfg, id: String) -> MLE<()> { | |||
50 | /// * `config` - The current config | 51 | /// * `config` - The current config |
51 | /// * `args` - All args, to extract the new version | 52 | /// * `args` - All args, to extract the new version |
52 | pub async fn list_version( | 53 | pub async fn list_version( |
53 | config: Cfg, | 54 | config: &Cfg, |
54 | id: String, | 55 | id: String, |
55 | mc_version: String, | 56 | mc_version: String, |
56 | download: bool, | 57 | download: bool, |
@@ -61,20 +62,20 @@ pub async fn list_version( | |||
61 | id, mc_version | 62 | id, mc_version |
62 | ); | 63 | ); |
63 | 64 | ||
64 | lists_version(config.clone(), &id, &mc_version)?; | 65 | lists_version(config, &id, &mc_version)?; |
65 | 66 | ||
66 | println!( | 67 | println!( |
67 | "\nCheck for updates for new minecraft version in list {}", | 68 | "\nCheck for updates for new minecraft version in list {}", |
68 | id | 69 | id |
69 | ); | 70 | ); |
70 | let list = lists_get(config.clone(), id)?; | 71 | let list = lists_get(config, id)?; |
71 | update(config, vec![list], true, download, delete).await | 72 | update(config, vec![list], true, download, delete).await |
72 | } | 73 | } |
73 | 74 | ||
74 | pub fn list_list(config: Cfg) -> MLE<()> { | 75 | pub fn list_list(config: &Cfg) -> MLE<()> { |
75 | let lists = lists_get_all_ids(config.clone())?; | 76 | let lists = lists_get_all_ids(config)?; |
76 | for list in lists { | 77 | for list in lists { |
77 | let l = lists_get(config.clone(), list)?; | 78 | let l = lists_get(config, list)?; |
78 | println!("{}: | {} | {}", l.id, l.mc_version, l.modloader) | 79 | println!("{}: | {} | {}", l.id, l.mc_version, l.modloader) |
79 | } | 80 | } |
80 | Ok(()) | 81 | Ok(()) |
diff --git a/src/commands/modification.rs b/src/commands/modification.rs index 730583d..31931f8 100644 --- a/src/commands/modification.rs +++ b/src/commands/modification.rs | |||
@@ -11,11 +11,9 @@ use crate::{ | |||
11 | error::{ErrorType, MLError, MLE}, | 11 | error::{ErrorType, MLError, MLE}, |
12 | files::{delete_version, download_versions}, | 12 | files::{delete_version, download_versions}, |
13 | modrinth::{extract_current_version, get_raw_versions, project, projects, versions, Version}, | 13 | modrinth::{extract_current_version, get_raw_versions, project, projects, versions, Version}, |
14 | List, | 14 | List, PROGRESS_CHARS, |
15 | }; | 15 | }; |
16 | 16 | ||
17 | const PROGRESS_CHARS: &str = "#>-"; | ||
18 | |||
19 | #[derive(Debug, Clone)] | 17 | #[derive(Debug, Clone)] |
20 | pub struct AddMod { | 18 | pub struct AddMod { |
21 | pub id: IDSelector, | 19 | pub id: IDSelector, |
@@ -40,7 +38,7 @@ pub struct ProjectInfo { | |||
40 | } | 38 | } |
41 | 39 | ||
42 | pub async fn mod_add( | 40 | pub async fn mod_add( |
43 | config: Cfg, | 41 | config: &Cfg, |
44 | mods: Vec<AddMod>, | 42 | mods: Vec<AddMod>, |
45 | list: List, | 43 | list: List, |
46 | direct_download: bool, | 44 | direct_download: bool, |
@@ -74,11 +72,11 @@ pub async fn mod_add( | |||
74 | info_p.set_style(bar_style.clone()); | 72 | info_p.set_style(bar_style.clone()); |
75 | let mut projectinfo: Vec<ProjectInfo> = Vec::new(); | 73 | let mut projectinfo: Vec<ProjectInfo> = Vec::new(); |
76 | if !mod_ids.is_empty() { | 74 | if !mod_ids.is_empty() { |
77 | projectinfo.append(&mut get_mod_infos(config.clone(), mod_ids, list.clone()).await?); | 75 | projectinfo.append(&mut get_mod_infos(config, mod_ids, list.clone()).await?); |
78 | info_p.inc(1); | 76 | info_p.inc(1); |
79 | }; | 77 | }; |
80 | if !ver_ids.is_empty() { | 78 | if !ver_ids.is_empty() { |
81 | projectinfo.append(&mut get_ver_info(config.clone(), ver_ids).await?); | 79 | projectinfo.append(&mut get_ver_info(config, ver_ids).await?); |
82 | info_p.inc(1); | 80 | info_p.inc(1); |
83 | }; | 81 | }; |
84 | 82 | ||
@@ -105,7 +103,7 @@ pub async fn mod_add( | |||
105 | }; | 103 | }; |
106 | 104 | ||
107 | match userlist_insert( | 105 | match userlist_insert( |
108 | config.clone(), | 106 | config, |
109 | &list.id, | 107 | &list.id, |
110 | &project.mod_id, | 108 | &project.mod_id, |
111 | ¤t_version_id, | 109 | ¤t_version_id, |
@@ -128,7 +126,7 @@ pub async fn mod_add( | |||
128 | }?; | 126 | }?; |
129 | 127 | ||
130 | match mods_insert( | 128 | match mods_insert( |
131 | config.clone(), | 129 | config, |
132 | &project.mod_id, | 130 | &project.mod_id, |
133 | &project.slug, | 131 | &project.slug, |
134 | &project.title, | 132 | &project.title, |
@@ -161,7 +159,7 @@ pub async fn mod_add( | |||
161 | Ok(()) | 159 | Ok(()) |
162 | } | 160 | } |
163 | 161 | ||
164 | async fn get_mod_infos(config: Cfg, mod_ids: Vec<(String, bool)>, list: List) -> MLE<Vec<ProjectInfo>> { | 162 | async fn get_mod_infos(config: &Cfg, mod_ids: Vec<(String, bool)>, list: List) -> MLE<Vec<ProjectInfo>> { |
165 | 163 | ||
166 | let mut setmap: HashMap<String, bool> = HashMap::new(); | 164 | let mut setmap: HashMap<String, bool> = HashMap::new(); |
167 | 165 | ||
@@ -255,7 +253,7 @@ async fn get_mod_infos(config: Cfg, mod_ids: Vec<(String, bool)>, list: List) -> | |||
255 | Ok(projectinfo) | 253 | Ok(projectinfo) |
256 | } | 254 | } |
257 | 255 | ||
258 | async fn get_ver_info(config: Cfg, ver_ids: Vec<(String, bool)>) -> MLE<Vec<ProjectInfo>> { | 256 | async fn get_ver_info(config: &Cfg, ver_ids: Vec<(String, bool)>) -> MLE<Vec<ProjectInfo>> { |
259 | 257 | ||
260 | let mut setmap: HashMap<String, bool> = HashMap::new(); | 258 | let mut setmap: HashMap<String, bool> = HashMap::new(); |
261 | 259 | ||
@@ -306,16 +304,16 @@ async fn get_ver_info(config: Cfg, ver_ids: Vec<(String, bool)>) -> MLE<Vec<Proj | |||
306 | /// * `config` - config struct | 304 | /// * `config` - config struct |
307 | /// * `id` - name, slug or id of the mod | 305 | /// * `id` - name, slug or id of the mod |
308 | /// * `list` - List struct | 306 | /// * `list` - List struct |
309 | pub fn mod_remove(config: Cfg, id: &str, list: List) -> MLE<()> { | 307 | pub fn mod_remove(config: &Cfg, id: &str, list: List) -> MLE<()> { |
310 | let mod_id = mods_get_id(&config.data, id)?; | 308 | let mod_id = mods_get_id(&config.data, id)?; |
311 | 309 | ||
312 | println!("Remove mod {} from {}", mods_get_info(&config, &mod_id)?.title, list.id); | 310 | println!("Remove mod {} from {}", mods_get_info(config, &mod_id)?.title, list.id); |
313 | let version = userlist_get_current_version(config.clone(), &list.id, &mod_id)?; | 311 | let version = userlist_get_current_version(config, &list.id, &mod_id)?; |
314 | 312 | ||
315 | print!(" └Remove from list"); | 313 | print!(" └Remove from list"); |
316 | //Force flush of stdout, else print! doesn't print instantly | 314 | //Force flush of stdout, else print! doesn't print instantly |
317 | std::io::stdout().flush()?; | 315 | std::io::stdout().flush()?; |
318 | userlist_remove(config.clone(), &list.id, &mod_id)?; | 316 | userlist_remove(config, &list.id, &mod_id)?; |
319 | println!(" ✓"); | 317 | println!(" ✓"); |
320 | 318 | ||
321 | print!(" └Delete file"); | 319 | print!(" └Delete file"); |
@@ -334,12 +332,12 @@ pub fn mod_remove(config: Cfg, id: &str, list: List) -> MLE<()> { | |||
334 | print!(" └Clean main db table"); | 332 | print!(" └Clean main db table"); |
335 | //Force flush of stdout, else print! doesn't print instantly | 333 | //Force flush of stdout, else print! doesn't print instantly |
336 | std::io::stdout().flush()?; | 334 | std::io::stdout().flush()?; |
337 | let list_ids = lists_get_all_ids(config.clone())?; | 335 | let list_ids = lists_get_all_ids(config)?; |
338 | 336 | ||
339 | // Remove mod from main list if not used elsewhere | 337 | // Remove mod from main list if not used elsewhere |
340 | let mut mod_used = false; | 338 | let mut mod_used = false; |
341 | for id in list_ids { | 339 | for id in list_ids { |
342 | let mods = match userlist_get_all_ids(config.clone(), &id) { | 340 | let mods = match userlist_get_all_ids(config, &id) { |
343 | Ok(m) => m, | 341 | Ok(m) => m, |
344 | Err(err) => { | 342 | Err(err) => { |
345 | if err.to_string() == "Database: NO_MODS_USERLIST" { | 343 | if err.to_string() == "Database: NO_MODS_USERLIST" { |
diff --git a/src/commands/update.rs b/src/commands/update.rs index 2de13f3..7482e43 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs | |||
@@ -9,13 +9,11 @@ use crate::{ | |||
9 | error::{ErrorType, MLError, MLE}, | 9 | error::{ErrorType, MLError, MLE}, |
10 | files::{clean_list_dir, delete_version, disable_version, download_versions}, | 10 | files::{clean_list_dir, delete_version, disable_version, download_versions}, |
11 | modrinth::{extract_current_version, versions, Version}, | 11 | modrinth::{extract_current_version, versions, Version}, |
12 | List, | 12 | List, PROGRESS_CHARS, |
13 | }; | 13 | }; |
14 | 14 | ||
15 | const PROGRESS_CHARS: &str = "#>-"; | ||
16 | |||
17 | pub async fn update( | 15 | pub async fn update( |
18 | config: Cfg, | 16 | config: &Cfg, |
19 | liststack: Vec<List>, | 17 | liststack: Vec<List>, |
20 | clean: bool, | 18 | clean: bool, |
21 | direct_download: bool, | 19 | direct_download: bool, |
@@ -33,7 +31,7 @@ pub async fn update( | |||
33 | for current_list in liststack { | 31 | for current_list in liststack { |
34 | 32 | ||
35 | // println!("Update mods in {}", current_list.id); | 33 | // println!("Update mods in {}", current_list.id); |
36 | let mods = userlist_get_all_ids(config.clone(), ¤t_list.id)?; | 34 | let mods = userlist_get_all_ids(config, ¤t_list.id)?; |
37 | 35 | ||
38 | let list_p = mp.insert_before(&update_p, ProgressBar::new(mods.len().try_into().unwrap())); | 36 | let list_p = mp.insert_before(&update_p, ProgressBar::new(mods.len().try_into().unwrap())); |
39 | list_p.set_style(bar_style.clone()); | 37 | list_p.set_style(bar_style.clone()); |
@@ -47,11 +45,11 @@ pub async fn update( | |||
47 | let mod_p = mp.insert_before(&list_p, ProgressBar::new(1)); | 45 | let mod_p = mp.insert_before(&list_p, ProgressBar::new(1)); |
48 | mod_p.set_style(spinner_style.clone()); | 46 | mod_p.set_style(spinner_style.clone()); |
49 | 47 | ||
50 | let info = mods_get_info(&config, &id)?; | 48 | let info = mods_get_info(config, &id)?; |
51 | mod_p.set_message(format!("Update {}", info.title)); | 49 | mod_p.set_message(format!("Update {}", info.title)); |
52 | // println!(" ├{}", info.title); | 50 | // println!(" ├{}", info.title); |
53 | 51 | ||
54 | if userlist_get_set_version(config.clone(), ¤t_list.id, &id)? { | 52 | if userlist_get_set_version(config, ¤t_list.id, &id)? { |
55 | // println!(" │ └Set version, skipping update"); | 53 | // println!(" │ └Set version, skipping update"); |
56 | list_p.inc(1); | 54 | list_p.inc(1); |
57 | continue; | 55 | continue; |
@@ -59,16 +57,16 @@ pub async fn update( | |||
59 | 57 | ||
60 | //Getting current installed version for disable or delete | 58 | //Getting current installed version for disable or delete |
61 | let disable_version = | 59 | let disable_version = |
62 | userlist_get_current_version(config.clone(), ¤t_list.id, &id)?; | 60 | userlist_get_current_version(config, ¤t_list.id, &id)?; |
63 | 61 | ||
64 | mod_p.inc(1); | 62 | mod_p.inc(1); |
65 | 63 | ||
66 | updatestack.push( | 64 | updatestack.push( |
67 | match specific_update( | 65 | match specific_update( |
68 | config.clone(), | 66 | config, |
69 | clean, | 67 | clean, |
70 | current_list.clone(), | 68 | current_list.clone(), |
71 | String::from(&id), | 69 | &id, |
72 | &mod_p | 70 | &mod_p |
73 | ) | 71 | ) |
74 | .await | 72 | .await |
@@ -112,7 +110,7 @@ pub async fn update( | |||
112 | delete_version(current_list.clone(), ver.0)?; | 110 | delete_version(current_list.clone(), ver.0)?; |
113 | } else if ver.0 != "NONE" { | 111 | } else if ver.0 != "NONE" { |
114 | println!(" └Disable version {}", ver.0); | 112 | println!(" └Disable version {}", ver.0); |
115 | disable_version(config.clone(), current_list.clone(), ver.0, ver.1)?; | 113 | disable_version(config, current_list.clone(), ver.0, ver.1)?; |
116 | }; | 114 | }; |
117 | } | 115 | } |
118 | } | 116 | } |
@@ -126,9 +124,9 @@ pub async fn update( | |||
126 | Ok(()) | 124 | Ok(()) |
127 | } | 125 | } |
128 | 126 | ||
129 | async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progress: &ProgressBar) -> MLE<Version> { | 127 | async fn specific_update(config: &Cfg, clean: bool, list: List, id: &str, progress: &ProgressBar) -> MLE<Version> { |
130 | let applicable_versions = | 128 | let applicable_versions = |
131 | versions(&config.apis.modrinth, String::from(&id), list.clone()).await; | 129 | versions(&config.apis.modrinth, String::from(id), list.clone()).await; |
132 | 130 | ||
133 | let mut versions: Vec<String> = vec![]; | 131 | let mut versions: Vec<String> = vec![]; |
134 | 132 | ||
@@ -144,9 +142,9 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progr | |||
144 | if clean | 142 | if clean |
145 | || (versions.join("|") | 143 | || (versions.join("|") |
146 | != userlist_get_applicable_versions( | 144 | != userlist_get_applicable_versions( |
147 | config.clone(), | 145 | config, |
148 | String::from(&list.id), | 146 | String::from(&list.id), |
149 | String::from(&id), | 147 | String::from(id), |
150 | )?) | 148 | )?) |
151 | { | 149 | { |
152 | let current_str = extract_current_version(applicable_versions.clone())?; | 150 | let current_str = extract_current_version(applicable_versions.clone())?; |
@@ -154,7 +152,7 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progr | |||
154 | if clean { | 152 | if clean { |
155 | // println!("\t └Add version to downloadstack"); | 153 | // println!("\t └Add version to downloadstack"); |
156 | } else { | 154 | } else { |
157 | progress.println(format!("Found new version for {}", mods_get_info(&config, &id).unwrap().title)); | 155 | progress.println(format!("Found new version for {}", mods_get_info(config, id).unwrap().title)); |
158 | // println!("\t └Get versions for specified minecraft versions"); | 156 | // println!("\t └Get versions for specified minecraft versions"); |
159 | // println!("\t └New current version: {}", current_str); | 157 | // println!("\t └New current version: {}", current_str); |
160 | }; | 158 | }; |
@@ -178,7 +176,7 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progr | |||
178 | } | 176 | } |
179 | .url; | 177 | .url; |
180 | 178 | ||
181 | userlist_change_versions(config, list.id, current_str, versions.join("|"), link, id)?; | 179 | userlist_change_versions(config, list.id, current_str, versions.join("|"), link, id.to_string())?; |
182 | } | 180 | } |
183 | 181 | ||
184 | if current.is_empty() { | 182 | if current.is_empty() { |