From 48393b209396db9ddd44251b2bb445d3ad7533fb Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Thu, 25 May 2023 17:23:52 +0200 Subject: changed a whole lot og references, fuck rust --- src/commands/list.rs | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/commands/list.rs') 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 { pub download_folder: String, } -pub fn get_current_list(config: Cfg) -> MLE { - let id = config_get_current_list(config.clone())?; +pub fn get_current_list(config: &Cfg) -> MLE { + let id = config_get_current_list(config)?; lists_get(config, id) } pub fn list_add( - config: Cfg, - id: String, - mc_version: String, - modloader: Modloader, - directory: String, + config: &Cfg, + id: &str, + mc_version: &str, + modloader: &Modloader, + directory: &str, ) -> MLE<()> { lists_insert(config, id, mc_version, modloader, directory) } -pub fn list_change(config: Cfg, id: String) -> MLE<()> { - if !lists_get_all_ids(config.clone())?.into_iter().any(|l| l == id) { +pub fn list_change(config: &Cfg, id: String) -> MLE<()> { + if !lists_get_all_ids(config)?.into_iter().any(|l| l == id) { return Err(MLError::new(ErrorType::ArgumentError, "List not found")); }; println!("Change default list to: {}", id); config_change_current_list(config, id) } -pub fn list_remove(config: Cfg, id: String) -> MLE<()> { +pub fn list_remove(config: &Cfg, id: String) -> MLE<()> { + //TODO add logging lists_remove(config, id) } @@ -50,7 +51,7 @@ pub fn list_remove(config: Cfg, id: String) -> MLE<()> { /// * `config` - The current config /// * `args` - All args, to extract the new version pub async fn list_version( - config: Cfg, + config: &Cfg, id: String, mc_version: String, download: bool, @@ -61,20 +62,20 @@ pub async fn list_version( id, mc_version ); - lists_version(config.clone(), &id, &mc_version)?; + lists_version(config, &id, &mc_version)?; println!( "\nCheck for updates for new minecraft version in list {}", id ); - let list = lists_get(config.clone(), id)?; + let list = lists_get(config, id)?; update(config, vec![list], true, download, delete).await } -pub fn list_list(config: Cfg) -> MLE<()> { - let lists = lists_get_all_ids(config.clone())?; +pub fn list_list(config: &Cfg) -> MLE<()> { + let lists = lists_get_all_ids(config)?; for list in lists { - let l = lists_get(config.clone(), list)?; + let l = lists_get(config, list)?; println!("{}: | {} | {}", l.id, l.mc_version, l.modloader) } Ok(()) -- cgit v1.2.3