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/modification.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/commands/modification.rs') 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::{ error::{ErrorType, MLError, MLE}, files::{delete_version, download_versions}, modrinth::{extract_current_version, get_raw_versions, project, projects, versions, Version}, - List, + List, PROGRESS_CHARS, }; -const PROGRESS_CHARS: &str = "#>-"; - #[derive(Debug, Clone)] pub struct AddMod { pub id: IDSelector, @@ -40,7 +38,7 @@ pub struct ProjectInfo { } pub async fn mod_add( - config: Cfg, + config: &Cfg, mods: Vec, list: List, direct_download: bool, @@ -74,11 +72,11 @@ pub async fn mod_add( info_p.set_style(bar_style.clone()); let mut projectinfo: Vec = Vec::new(); if !mod_ids.is_empty() { - projectinfo.append(&mut get_mod_infos(config.clone(), mod_ids, list.clone()).await?); + projectinfo.append(&mut get_mod_infos(config, mod_ids, list.clone()).await?); info_p.inc(1); }; if !ver_ids.is_empty() { - projectinfo.append(&mut get_ver_info(config.clone(), ver_ids).await?); + projectinfo.append(&mut get_ver_info(config, ver_ids).await?); info_p.inc(1); }; @@ -105,7 +103,7 @@ pub async fn mod_add( }; match userlist_insert( - config.clone(), + config, &list.id, &project.mod_id, ¤t_version_id, @@ -128,7 +126,7 @@ pub async fn mod_add( }?; match mods_insert( - config.clone(), + config, &project.mod_id, &project.slug, &project.title, @@ -161,7 +159,7 @@ pub async fn mod_add( Ok(()) } -async fn get_mod_infos(config: Cfg, mod_ids: Vec<(String, bool)>, list: List) -> MLE> { +async fn get_mod_infos(config: &Cfg, mod_ids: Vec<(String, bool)>, list: List) -> MLE> { let mut setmap: HashMap = HashMap::new(); @@ -255,7 +253,7 @@ async fn get_mod_infos(config: Cfg, mod_ids: Vec<(String, bool)>, list: List) -> Ok(projectinfo) } -async fn get_ver_info(config: Cfg, ver_ids: Vec<(String, bool)>) -> MLE> { +async fn get_ver_info(config: &Cfg, ver_ids: Vec<(String, bool)>) -> MLE> { let mut setmap: HashMap = HashMap::new(); @@ -306,16 +304,16 @@ async fn get_ver_info(config: Cfg, ver_ids: Vec<(String, bool)>) -> MLE MLE<()> { +pub fn mod_remove(config: &Cfg, id: &str, list: List) -> MLE<()> { let mod_id = mods_get_id(&config.data, id)?; - println!("Remove mod {} from {}", mods_get_info(&config, &mod_id)?.title, list.id); - let version = userlist_get_current_version(config.clone(), &list.id, &mod_id)?; + println!("Remove mod {} from {}", mods_get_info(config, &mod_id)?.title, list.id); + let version = userlist_get_current_version(config, &list.id, &mod_id)?; print!(" └Remove from list"); //Force flush of stdout, else print! doesn't print instantly std::io::stdout().flush()?; - userlist_remove(config.clone(), &list.id, &mod_id)?; + userlist_remove(config, &list.id, &mod_id)?; println!(" ✓"); print!(" └Delete file"); @@ -334,12 +332,12 @@ pub fn mod_remove(config: Cfg, id: &str, list: List) -> MLE<()> { print!(" └Clean main db table"); //Force flush of stdout, else print! doesn't print instantly std::io::stdout().flush()?; - let list_ids = lists_get_all_ids(config.clone())?; + let list_ids = lists_get_all_ids(config)?; // Remove mod from main list if not used elsewhere let mut mod_used = false; for id in list_ids { - let mods = match userlist_get_all_ids(config.clone(), &id) { + let mods = match userlist_get_all_ids(config, &id) { Ok(m) => m, Err(err) => { if err.to_string() == "Database: NO_MODS_USERLIST" { -- cgit v1.2.3