summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/download.rs6
-rw-r--r--src/commands/io.rs34
-rw-r--r--src/commands/list.rs33
-rw-r--r--src/commands/modification.rs30
-rw-r--r--src/commands/update.rs32
-rw-r--r--src/config.rs1
-rw-r--r--src/db.rs70
-rw-r--r--src/files.rs8
-rw-r--r--src/lib.rs2
-rw-r--r--src/main.rs56
10 files changed, 134 insertions, 138 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
12pub async fn download(config: Cfg, liststack: Vec<List>, clean: bool, delete_old: bool) -> MLE<()> { 12pub 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(&current_list.id), 19 String::from(&current_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
23impl ExportVersion { 23impl 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
41impl ExportList { 41impl 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
66pub fn export(config: Cfg, list: Option<String>) -> MLE<()> { 66pub 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
88pub async fn import(config: Cfg, file_str: String, direct_download: bool) -> MLE<()> { 88pub 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
19pub fn get_current_list(config: Cfg) -> MLE<List> { 19pub 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
24pub fn list_add( 24pub 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
34pub fn list_change(config: Cfg, id: String) -> MLE<()> { 34pub 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
42pub fn list_remove(config: Cfg, id: String) -> MLE<()> { 42pub 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
52pub async fn list_version( 53pub 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
74pub fn list_list(config: Cfg) -> MLE<()> { 75pub 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
17const PROGRESS_CHARS: &str = "#>-";
18
19#[derive(Debug, Clone)] 17#[derive(Debug, Clone)]
20pub struct AddMod { 18pub struct AddMod {
21 pub id: IDSelector, 19 pub id: IDSelector,
@@ -40,7 +38,7 @@ pub struct ProjectInfo {
40} 38}
41 39
42pub async fn mod_add( 40pub 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 &current_version_id, 109 &current_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
164async fn get_mod_infos(config: Cfg, mod_ids: Vec<(String, bool)>, list: List) -> MLE<Vec<ProjectInfo>> { 162async 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
258async fn get_ver_info(config: Cfg, ver_ids: Vec<(String, bool)>) -> MLE<Vec<ProjectInfo>> { 256async 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
309pub fn mod_remove(config: Cfg, id: &str, list: List) -> MLE<()> { 307pub 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
15const PROGRESS_CHARS: &str = "#>-";
16
17pub async fn update( 15pub 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(), &current_list.id)?; 34 let mods = userlist_get_all_ids(config, &current_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(), &current_list.id, &id)? { 52 if userlist_get_set_version(config, &current_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(), &current_list.id, &id)?; 60 userlist_get_current_version(config, &current_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
129async fn specific_update(config: Cfg, clean: bool, list: List, id: String, progress: &ProgressBar) -> MLE<Version> { 127async 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() {
diff --git a/src/config.rs b/src/config.rs
index 0cb1891..a952d40 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -73,6 +73,7 @@ impl Cfg {
73 check_game_versions(&versionfile, true).await?; 73 check_game_versions(&versionfile, true).await?;
74 }, 74 },
75 } 75 }
76
76 Ok(config) 77 Ok(config)
77 } 78 }
78} 79}
diff --git a/src/db.rs b/src/db.rs
index dde00ab..3409298 100644
--- a/src/db.rs
+++ b/src/db.rs
@@ -9,7 +9,7 @@ use crate::{
9}; 9};
10 10
11//MODS 11//MODS
12pub fn mods_insert(config: Cfg, id: &str, slug: &str, name: &str) -> MLE<()> { 12pub fn mods_insert(config: &Cfg, id: &str, slug: &str, name: &str) -> MLE<()> {
13 let data = format!("{}/data.db", config.data); 13 let data = format!("{}/data.db", config.data);
14 let connection = Connection::open(data)?; 14 let connection = Connection::open(data)?;
15 15
@@ -21,7 +21,7 @@ pub fn mods_insert(config: Cfg, id: &str, slug: &str, name: &str) -> MLE<()> {
21 Ok(()) 21 Ok(())
22} 22}
23 23
24pub fn mods_get_all_ids(config: Cfg) -> Result<Vec<String>, Box<dyn std::error::Error>> { 24pub fn mods_get_all_ids(config: &Cfg) -> Result<Vec<String>, Box<dyn std::error::Error>> {
25 let data = format!("{}/data.db", config.data); 25 let data = format!("{}/data.db", config.data);
26 let connection = Connection::open(data).unwrap(); 26 let connection = Connection::open(data).unwrap();
27 27
@@ -120,7 +120,7 @@ pub fn mods_get_info(config: &Cfg, id: &str) -> MLE<ModInfo> {
120 } 120 }
121} 121}
122 122
123pub fn mods_remove(config: Cfg, id: String) -> MLE<()> { 123pub fn mods_remove(config: &Cfg, id: String) -> MLE<()> {
124 println!("Removing mod {} from database", id); 124 println!("Removing mod {} from database", id);
125 125
126 let data = format!("{}/data.db", config.data); 126 let data = format!("{}/data.db", config.data);
@@ -137,7 +137,7 @@ pub struct DBModlistVersions {
137 pub versions: String, 137 pub versions: String,
138} 138}
139 139
140pub fn mods_get_versions(config: Cfg, mods: Vec<String>) -> MLE<Vec<DBModlistVersions>> { 140pub fn mods_get_versions(config: &Cfg, mods: Vec<String>) -> MLE<Vec<DBModlistVersions>> {
141 let data = format!("{}/data.db", config.data); 141 let data = format!("{}/data.db", config.data);
142 let connection = Connection::open(data)?; 142 let connection = Connection::open(data)?;
143 143
@@ -186,7 +186,7 @@ pub fn mods_get_versions(config: Cfg, mods: Vec<String>) -> MLE<Vec<DBModlistVer
186 186
187//userlist 187//userlist
188pub fn userlist_insert( 188pub fn userlist_insert(
189 config: Cfg, 189 config: &Cfg,
190 list_id: &str, 190 list_id: &str,
191 mod_id: &str, 191 mod_id: &str,
192 current_version: &str, 192 current_version: &str,
@@ -220,7 +220,7 @@ pub fn userlist_insert(
220 Ok(()) 220 Ok(())
221} 221}
222 222
223pub fn userlist_get_all_ids(config: Cfg, list_id: &str) -> MLE<Vec<String>> { 223pub fn userlist_get_all_ids(config: &Cfg, list_id: &str) -> MLE<Vec<String>> {
224 let data = format!("{}/data.db", config.data); 224 let data = format!("{}/data.db", config.data);
225 let connection = Connection::open(data).unwrap(); 225 let connection = Connection::open(data).unwrap();
226 226
@@ -239,7 +239,7 @@ pub fn userlist_get_all_ids(config: Cfg, list_id: &str) -> MLE<Vec<String>> {
239 } 239 }
240} 240}
241 241
242pub fn userlist_remove(config: Cfg, list_id: &str, mod_id: &str) -> MLE<()> { 242pub fn userlist_remove(config: &Cfg, list_id: &str, mod_id: &str) -> MLE<()> {
243 let data = format!("{}/data.db", config.data); 243 let data = format!("{}/data.db", config.data);
244 let connection = Connection::open(data)?; 244 let connection = Connection::open(data)?;
245 245
@@ -251,7 +251,7 @@ pub fn userlist_remove(config: Cfg, list_id: &str, mod_id: &str) -> MLE<()> {
251} 251}
252 252
253pub fn userlist_get_applicable_versions( 253pub fn userlist_get_applicable_versions(
254 config: Cfg, 254 config: &Cfg,
255 list_id: String, 255 list_id: String,
256 mod_id: String, 256 mod_id: String,
257) -> MLE<String> { 257) -> MLE<String> {
@@ -279,7 +279,7 @@ pub fn userlist_get_applicable_versions(
279} 279}
280 280
281pub fn userlist_get_all_applicable_versions_with_mods( 281pub fn userlist_get_all_applicable_versions_with_mods(
282 config: Cfg, 282 config: &Cfg,
283 list_id: String, 283 list_id: String,
284) -> MLE<Vec<(String, String)>> { 284) -> MLE<Vec<(String, String)>> {
285 let data = format!("{}/data.db", config.data); 285 let data = format!("{}/data.db", config.data);
@@ -307,7 +307,7 @@ pub fn userlist_get_all_applicable_versions_with_mods(
307 Ok(versions) 307 Ok(versions)
308} 308}
309 309
310pub fn userlist_get_current_version(config: Cfg, list_id: &str, mod_id: &str) -> MLE<String> { 310pub fn userlist_get_current_version(config: &Cfg, list_id: &str, mod_id: &str) -> MLE<String> {
311 let data = format!("{}/data.db", config.data); 311 let data = format!("{}/data.db", config.data);
312 let connection = Connection::open(data).unwrap(); 312 let connection = Connection::open(data).unwrap();
313 313
@@ -327,7 +327,7 @@ pub fn userlist_get_current_version(config: Cfg, list_id: &str, mod_id: &str) ->
327} 327}
328 328
329pub fn userlist_get_all_current_version_ids( 329pub fn userlist_get_all_current_version_ids(
330 config: Cfg, 330 config: &Cfg,
331 list_id: String, 331 list_id: String,
332) -> MLE<Vec<String>> { 332) -> MLE<Vec<String>> {
333 let data = format!("{}/data.db", config.data); 333 let data = format!("{}/data.db", config.data);
@@ -353,7 +353,7 @@ pub fn userlist_get_all_current_version_ids(
353} 353}
354 354
355pub fn userlist_get_all_current_versions_with_mods( 355pub fn userlist_get_all_current_versions_with_mods(
356 config: Cfg, 356 config: &Cfg,
357 list_id: String, 357 list_id: String,
358) -> Result<Vec<(String, String)>, Box<dyn std::error::Error>> { 358) -> Result<Vec<(String, String)>, Box<dyn std::error::Error>> {
359 let data = format!("{}/data.db", config.data); 359 let data = format!("{}/data.db", config.data);
@@ -384,7 +384,7 @@ pub fn userlist_get_all_current_versions_with_mods(
384 Ok(versions) 384 Ok(versions)
385} 385}
386 386
387pub fn userlist_get_set_version(config: Cfg, list_id: &str, mod_id: &str) -> MLE<bool> { 387pub fn userlist_get_set_version(config: &Cfg, list_id: &str, mod_id: &str) -> MLE<bool> {
388 let data = format!("{}/data.db", config.data); 388 let data = format!("{}/data.db", config.data);
389 let connection = Connection::open(data).unwrap(); 389 let connection = Connection::open(data).unwrap();
390 390
@@ -401,7 +401,7 @@ pub fn userlist_get_set_version(config: Cfg, list_id: &str, mod_id: &str) -> MLE
401} 401}
402 402
403pub fn userlist_change_versions( 403pub fn userlist_change_versions(
404 config: Cfg, 404 config: &Cfg,
405 list_id: String, 405 list_id: String,
406 current_version: String, 406 current_version: String,
407 versions: String, 407 versions: String,
@@ -416,7 +416,7 @@ pub fn userlist_change_versions(
416} 416}
417 417
418pub fn userlist_add_disabled_versions( 418pub fn userlist_add_disabled_versions(
419 config: Cfg, 419 config: &Cfg,
420 list_id: String, 420 list_id: String,
421 disabled_version: String, 421 disabled_version: String,
422 mod_id: String, 422 mod_id: String,
@@ -442,7 +442,7 @@ pub fn userlist_add_disabled_versions(
442 Ok(()) 442 Ok(())
443} 443}
444 444
445pub fn userlist_get_disabled_versions(config: Cfg, list_id: String, mod_id: String) -> MLE<String> { 445pub fn userlist_get_disabled_versions(config: &Cfg, list_id: String, mod_id: String) -> MLE<String> {
446 let data = format!("{}/data.db", config.data); 446 let data = format!("{}/data.db", config.data);
447 let connection = Connection::open(data).unwrap(); 447 let connection = Connection::open(data).unwrap();
448 448
@@ -462,7 +462,7 @@ pub fn userlist_get_disabled_versions(config: Cfg, list_id: String, mod_id: Stri
462} 462}
463 463
464pub fn userlist_get_all_downloads( 464pub fn userlist_get_all_downloads(
465 config: Cfg, 465 config: &Cfg,
466 list_id: String, 466 list_id: String,
467) -> Result<Vec<String>, Box<dyn std::error::Error>> { 467) -> Result<Vec<String>, Box<dyn std::error::Error>> {
468 let data = format!("{}/data.db", config.data); 468 let data = format!("{}/data.db", config.data);
@@ -492,11 +492,11 @@ pub fn userlist_get_all_downloads(
492//lists 492//lists
493///Inserts into lists table and creates new table 493///Inserts into lists table and creates new table
494pub fn lists_insert( 494pub fn lists_insert(
495 config: Cfg, 495 config: &Cfg,
496 id: String, 496 id: &str,
497 mc_version: String, 497 mc_version: &str,
498 mod_loader: Modloader, 498 mod_loader: &Modloader,
499 download_folder: String, 499 download_folder: &str,
500) -> MLE<()> { 500) -> MLE<()> {
501 println!("Creating list {}", id); 501 println!("Creating list {}", id);
502 502
@@ -506,9 +506,9 @@ pub fn lists_insert(
506 connection.execute( 506 connection.execute(
507 "INSERT INTO lists VALUES (?1, ?2, ?3, ?4)", 507 "INSERT INTO lists VALUES (?1, ?2, ?3, ?4)",
508 [ 508 [
509 id.clone(), 509 id,
510 mc_version, 510 mc_version,
511 mod_loader.to_string(), 511 &mod_loader.to_string(),
512 download_folder, 512 download_folder,
513 ], 513 ],
514 )?; 514 )?;
@@ -517,7 +517,7 @@ pub fn lists_insert(
517 Ok(()) 517 Ok(())
518} 518}
519 519
520pub fn lists_remove(config: Cfg, id: String) -> MLE<()> { 520pub fn lists_remove(config: &Cfg, id: String) -> MLE<()> {
521 let data = format!("{}/data.db", config.data); 521 let data = format!("{}/data.db", config.data);
522 let connection = Connection::open(data)?; 522 let connection = Connection::open(data)?;
523 523
@@ -526,7 +526,7 @@ pub fn lists_remove(config: Cfg, id: String) -> MLE<()> {
526 Ok(()) 526 Ok(())
527} 527}
528 528
529pub fn lists_get(config: Cfg, list_id: String) -> MLE<List> { 529pub fn lists_get(config: &Cfg, list_id: String) -> MLE<List> {
530 let data = format!("{}/data.db", config.data); 530 let data = format!("{}/data.db", config.data);
531 let connection = Connection::open(data).unwrap(); 531 let connection = Connection::open(data).unwrap();
532 532
@@ -564,7 +564,7 @@ pub fn lists_get(config: Cfg, list_id: String) -> MLE<List> {
564 Ok(list) 564 Ok(list)
565} 565}
566 566
567pub fn lists_version(config: Cfg, list_id: &str, version: &str) -> MLE<()> { 567pub fn lists_version(config: &Cfg, list_id: &str, version: &str) -> MLE<()> {
568 let data = format!("{}/data.db", config.data); 568 let data = format!("{}/data.db", config.data);
569 let connection = Connection::open(data).unwrap(); 569 let connection = Connection::open(data).unwrap();
570 570
@@ -575,7 +575,7 @@ pub fn lists_version(config: Cfg, list_id: &str, version: &str) -> MLE<()> {
575 Ok(()) 575 Ok(())
576} 576}
577 577
578pub fn lists_get_all_ids(config: Cfg) -> MLE<Vec<String>> { 578pub fn lists_get_all_ids(config: &Cfg) -> MLE<Vec<String>> {
579 let data = format!("{}/data.db", config.data); 579 let data = format!("{}/data.db", config.data);
580 let connection = Connection::open(data).unwrap(); 580 let connection = Connection::open(data).unwrap();
581 581
@@ -594,7 +594,7 @@ pub fn lists_get_all_ids(config: Cfg) -> MLE<Vec<String>> {
594} 594}
595 595
596//config 596//config
597pub fn config_change_current_list(config: Cfg, id: String) -> MLE<()> { 597pub fn config_change_current_list(config: &Cfg, id: String) -> MLE<()> {
598 let data = format!("{}/data.db", config.data); 598 let data = format!("{}/data.db", config.data);
599 let connection = Connection::open(data)?; 599 let connection = Connection::open(data)?;
600 600
@@ -605,7 +605,7 @@ pub fn config_change_current_list(config: Cfg, id: String) -> MLE<()> {
605 Ok(()) 605 Ok(())
606} 606}
607 607
608pub fn config_get_current_list(config: Cfg) -> MLE<String> { 608pub fn config_get_current_list(config: &Cfg) -> MLE<String> {
609 let data = format!("{}/data.db", config.data); 609 let data = format!("{}/data.db", config.data);
610 let connection = Connection::open(data).unwrap(); 610 let connection = Connection::open(data).unwrap();
611 611
@@ -626,7 +626,7 @@ pub fn config_get_current_list(config: Cfg) -> MLE<String> {
626 626
627//SETUP(UPDATES) 627//SETUP(UPDATES)
628pub fn s_userlist_update_download( 628pub fn s_userlist_update_download(
629 config: Cfg, 629 config: &Cfg,
630 list_id: String, 630 list_id: String,
631 mod_id: String, 631 mod_id: String,
632 link: String, 632 link: String,
@@ -645,7 +645,7 @@ pub fn s_userlist_update_download(
645 Ok(()) 645 Ok(())
646} 646}
647 647
648pub fn s_config_create_version(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { 648pub fn s_config_create_version(config: &Cfg) -> Result<(), Box<dyn std::error::Error>> {
649 let data = format!("{}/data.db", config.data); 649 let data = format!("{}/data.db", config.data);
650 let connection = Connection::open(data)?; 650 let connection = Connection::open(data)?;
651 651
@@ -656,7 +656,7 @@ pub fn s_config_create_version(config: Cfg) -> Result<(), Box<dyn std::error::Er
656 Ok(()) 656 Ok(())
657} 657}
658 658
659pub fn s_config_update_version(config: Cfg, ver: String) -> Result<(), Box<dyn std::error::Error>> { 659pub fn s_config_update_version(config: &Cfg, ver: String) -> Result<(), Box<dyn std::error::Error>> {
660 let data = format!("{}/data.db", config.data); 660 let data = format!("{}/data.db", config.data);
661 let connection = Connection::open(data)?; 661 let connection = Connection::open(data)?;
662 662
@@ -667,7 +667,7 @@ pub fn s_config_update_version(config: Cfg, ver: String) -> Result<(), Box<dyn s
667 Ok(()) 667 Ok(())
668} 668}
669 669
670pub fn s_config_get_version(config: Cfg) -> Result<String, Box<dyn std::error::Error>> { 670pub fn s_config_get_version(config: &Cfg) -> Result<String, Box<dyn std::error::Error>> {
671 let data = format!("{}/data.db", config.data); 671 let data = format!("{}/data.db", config.data);
672 let connection = Connection::open(data)?; 672 let connection = Connection::open(data)?;
673 673
@@ -689,7 +689,7 @@ pub fn s_config_get_version(config: Cfg) -> Result<String, Box<dyn std::error::E
689} 689}
690 690
691pub fn s_insert_column( 691pub fn s_insert_column(
692 config: Cfg, 692 config: &Cfg,
693 table: String, 693 table: String,
694 column: String, 694 column: String,
695 c_type: String, 695 c_type: String,
diff --git a/src/files.rs b/src/files.rs
index 04b00f0..565d2b6 100644
--- a/src/files.rs
+++ b/src/files.rs
@@ -14,11 +14,9 @@ use crate::{
14 db::{mods_get_info, userlist_add_disabled_versions}, 14 db::{mods_get_info, userlist_add_disabled_versions},
15 error::{ErrorType, MLError, MLE}, 15 error::{ErrorType, MLError, MLE},
16 modrinth::Version, 16 modrinth::Version,
17 List, 17 List, PROGRESS_CHARS,
18}; 18};
19 19
20const PROGRESS_CHARS: &str = "#>-";
21
22pub async fn download_versions(list: List, config: Cfg, versions: Vec<Version>) -> MLE<()> { 20pub async fn download_versions(list: List, config: Cfg, versions: Vec<Version>) -> MLE<()> {
23 let cached = get_cached_versions(&config.cache); 21 let cached = get_cached_versions(&config.cache);
24 22
@@ -89,7 +87,7 @@ async fn download_version(config: Cfg, list: List, version: Version, mut cached:
89 87
90 progress.set_message(format!("Copy {} to cache", version.id)); 88 progress.set_message(format!("Copy {} to cache", version.id));
91 let dl_path_file = format!("{}/{}", list.download_folder, filename); 89 let dl_path_file = format!("{}/{}", list.download_folder, filename);
92 let cache_path = format!("{}/{}", &config.clone().cache, filename); 90 let cache_path = format!("{}/{}", &config.cache, filename);
93 91
94 copy(dl_path_file, cache_path)?; 92 copy(dl_path_file, cache_path)?;
95 } 93 }
@@ -135,7 +133,7 @@ async fn download_file(url: &str, path: &str, name: &str, progress: &ProgressBar
135} 133}
136 134
137pub fn disable_version( 135pub fn disable_version(
138 config: Cfg, 136 config: &Cfg,
139 current_list: List, 137 current_list: List,
140 versionid: String, 138 versionid: String,
141 mod_id: String, 139 mod_id: String,
diff --git a/src/lib.rs b/src/lib.rs
index f59ba89..69cc650 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -14,7 +14,7 @@ pub use commands::*;
14use error::{ErrorType, MLError, MLE}; 14use error::{ErrorType, MLError, MLE};
15use serde::{Deserialize, Serialize}; 15use serde::{Deserialize, Serialize};
16 16
17pub static TICK_CHARS: &str = "#>-"; 17pub static PROGRESS_CHARS: &str = "#>-";
18 18
19#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)] 19#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize)]
20pub enum Modloader { 20pub enum Modloader {
diff --git a/src/main.rs b/src/main.rs
index 31a320b..0e040b6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -162,7 +162,6 @@ async fn main() {
162 match cli.command { 162 match cli.command {
163 Commands::Mod { command } => { 163 Commands::Mod { command } => {
164 match command { 164 match command {
165 #[allow(unused_variables)]
166 ModCommands::Add { 165 ModCommands::Add {
167 id, 166 id,
168 version, 167 version,
@@ -171,10 +170,10 @@ async fn main() {
171 lock, 170 lock,
172 } => { 171 } => {
173 let listf = match list { 172 let listf = match list {
174 Some(list) => lists_get(config.clone(), list).unwrap(), 173 Some(list) => lists_get(&config, list).unwrap(),
175 None => lists_get( 174 None => lists_get(
176 config.clone(), 175 &config,
177 config_get_current_list(config.clone()).unwrap(), 176 config_get_current_list(&config).unwrap(),
178 ) 177 )
179 .unwrap(), 178 .unwrap(),
180 }; 179 };
@@ -186,18 +185,18 @@ async fn main() {
186 185
187 let add_id = AddMod { id: marked_id, set_version: lock }; 186 let add_id = AddMod { id: marked_id, set_version: lock };
188 187
189 mod_add(config, vec![add_id], listf, download).await 188 mod_add(&config, vec![add_id], listf, download).await
190 } 189 }
191 ModCommands::Remove { id, list } => { 190 ModCommands::Remove { id, list } => {
192 let listf = match list { 191 let listf = match list {
193 Some(list) => lists_get(config.clone(), list).unwrap(), 192 Some(list) => lists_get(&config, list).unwrap(),
194 None => lists_get( 193 None => lists_get(
195 config.clone(), 194 &config,
196 config_get_current_list(config.clone()).unwrap(), 195 config_get_current_list(&config).unwrap(),
197 ) 196 )
198 .unwrap(), 197 .unwrap(),
199 }; 198 };
200 mod_remove(config, &id, listf) 199 mod_remove(&config, &id, listf)
201 } 200 }
202 } 201 }
203 } 202 }
@@ -211,28 +210,28 @@ async fn main() {
211 } => { 210 } => {
212 let ml = match modloader { 211 let ml = match modloader {
213 Some(ml) => Modloader::from(&ml).unwrap(), 212 Some(ml) => Modloader::from(&ml).unwrap(),
214 None => config.clone().defaults.modloader, 213 None => config.defaults.modloader.clone(),
215 }; 214 };
216 215
217 let versions_path = &config.versions; 216 let versions_path = &config.versions;
218 let ver = match version { 217 let ver = match version {
219 Some(ver) => VersionLevel::from(&ver).get(versions_path, cli.force_gameupdate).await.unwrap(), 218 Some(ver) => VersionLevel::from(&ver).get(versions_path, cli.force_gameupdate).await.unwrap(),
220 None => config.clone().defaults.version.get(versions_path, cli.force_gameupdate).await.unwrap(), 219 None => config.defaults.version.clone().get(versions_path, cli.force_gameupdate).await.unwrap(),
221 }; 220 };
222 221
223 list_add(config, id, ver, ml, directory) 222 list_add(&config, &id, &ver, &ml, &directory)
224 } 223 }
225 ListCommands::Remove { id } => list_remove(config, id), 224 ListCommands::Remove { id } => list_remove(&config, id),
226 ListCommands::List => { 225 ListCommands::List => {
227 list_list(config) 226 list_list(&config)
228 } 227 }
229 ListCommands::Change { id } => list_change(config, id), 228 ListCommands::Change { id } => list_change(&config, id),
230 ListCommands::Version { 229 ListCommands::Version {
231 id, 230 id,
232 version, 231 version,
233 download, 232 download,
234 remove, 233 remove,
235 } => list_version(config, id, version, download, remove).await, 234 } => list_version(&config, id, version, download, remove).await,
236 } 235 }
237 } 236 }
238 Commands::Update { 237 Commands::Update {
@@ -244,34 +243,35 @@ async fn main() {
244 } => { 243 } => {
245 let mut liststack: Vec<List> = vec![]; 244 let mut liststack: Vec<List> = vec![];
246 if all { 245 if all {
247 let list_ids = lists_get_all_ids(config.clone()).unwrap(); 246 let list_ids = lists_get_all_ids(&config).unwrap();
248 for id in list_ids { 247 for id in list_ids {
249 liststack.push(lists_get(config.clone(), id).unwrap()); 248 liststack.push(lists_get(&config, id).unwrap());
250 } 249 }
251 } else { 250 } else {
252 let current = match list { 251 let current = match list {
253 Some(l) => lists_get(config.clone(), l).unwrap(), 252 Some(l) => lists_get(&config, l).unwrap(),
254 None => get_current_list(config.clone()).unwrap(), 253 None => get_current_list(&config).unwrap(),
255 }; 254 };
256 liststack.push(current) 255 liststack.push(current)
257 } 256 }
258 update(config, liststack, clean, download, remove).await 257 update(&config, liststack, clean, download, remove).await
259 } 258 }
260 Commands::Download { all, clean, remove, list } => { 259 Commands::Download { all, clean, remove, list } => {
261 let mut liststack: Vec<List> = vec![]; 260 let mut liststack: Vec<List> = vec![];
262 if all { 261 if all {
263 let list_ids = lists_get_all_ids(config.clone()).unwrap(); 262 let list_ids = lists_get_all_ids(&config).unwrap();
264 for id in list_ids { 263 for id in list_ids {
265 liststack.push(lists_get(config.clone(), id).unwrap()); 264 liststack.push(lists_get(&config, id).unwrap());
266 } 265 }
267 } else { 266 } else {
268 let current = match list { 267 let current = match list {
269 Some(l) => lists_get(config.clone(), l).unwrap(), 268 Some(l) => lists_get(&config, l).unwrap(),
270 None => get_current_list(config.clone()).unwrap(), 269 None => get_current_list(&config).unwrap(),
271 }; 270 };
272 liststack.push(current) 271 liststack.push(current)
273 } 272 }
274 download(config, liststack, clean, remove).await 273
274 download(&config, liststack, clean, remove).await
275 }, 275 },
276 Commands::Import { file, download } => { 276 Commands::Import { file, download } => {
277 let filestr: String = match file { 277 let filestr: String = match file {
@@ -284,9 +284,9 @@ async fn main() {
284 .unwrap(), 284 .unwrap(),
285 }; 285 };
286 286
287 import(config, filestr, download).await 287 import(&config, filestr, download).await
288 } 288 }
289 Commands::Export { list } => export(config, list), 289 Commands::Export { list } => export(&config, list),
290 Commands::Test => Ok(()), 290 Commands::Test => Ok(()),
291 } 291 }
292 .unwrap(); 292 .unwrap();