summaryrefslogtreecommitdiff
path: root/src/commands/list.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/list.rs')
-rw-r--r--src/commands/list.rs33
1 files changed, 17 insertions, 16 deletions
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(())