From 93e61a4bd6ad8b5db1083bdd21994bf73b0b90ba Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 17 Apr 2023 20:30:16 +0200 Subject: added clap cli, modified (basically) all user interface functions; changed some functions to easier string handling --- src/commands/update.rs | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'src/commands/update.rs') diff --git a/src/commands/update.rs b/src/commands/update.rs index 75bee39..e5751c0 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -1,21 +1,6 @@ -use crate::{config::Cfg, modrinth::{versions, extract_current_version, Version}, get_current_list, db::{userlist_get_all_ids, userlist_get_applicable_versions, userlist_change_versions, lists_get_all_ids, lists_get, userlist_get_current_version, userlist_get_set_version, mods_get_info}, List, input::Input, files::{delete_version, download_versions, disable_version, clean_list_dir}, error::{MLE, MLError, ErrorType}}; - -pub async fn update(config: Cfg, input: Input) -> MLE<()> { - let mut liststack: Vec = vec![]; - if input.all_lists { - let list_ids = lists_get_all_ids(config.clone())?; - for id in list_ids { - liststack.push(lists_get(config.clone(), id)?); - } - } else { - let current = get_current_list(config.clone())?; - println!("Update list {}:", current.id); - liststack.push(current) - } - cmd_update(config, liststack, input.clean, input.direct_download, input.delete_old).await -} +use crate::{config::Cfg, modrinth::{versions, extract_current_version, Version}, db::{userlist_get_all_ids, userlist_get_applicable_versions, userlist_change_versions, userlist_get_current_version, userlist_get_set_version, mods_get_info}, List, files::{delete_version, download_versions, disable_version, clean_list_dir}, error::{MLE, MLError, ErrorType}}; -pub async fn cmd_update(config: Cfg, liststack: Vec, clean: bool, direct_download: bool, delete_old: bool) -> MLE<()> { +pub async fn update(config: Cfg, liststack: Vec, clean: bool, direct_download: bool, delete_old: bool) -> MLE<()> { for current_list in liststack { let mods = userlist_get_all_ids(config.clone(), current_list.clone().id)?; @@ -34,7 +19,7 @@ pub async fn cmd_update(config: Cfg, liststack: Vec, clean: bool, direct_d } //Getting current installed version for disable or delete - let disable_version = userlist_get_current_version(config.clone(), String::from(¤t_list.id), String::from(&id))?; + let disable_version = userlist_get_current_version(config.clone(), ¤t_list.id, &id)?; updatestack.push( match specific_update(config.clone(), clean, current_list.clone(), String::from(&id)).await { @@ -110,6 +95,7 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String) -> ML }?; current.push(current_ver.clone()); + //TODO implement version selection if no primary let link = match current_ver.files.into_iter().find(|f| f.primary).ok_or("!no primary in links") { Ok(p) => Ok(p), Err(e) => Err(MLError::new(ErrorType::Other, e)), -- cgit v1.2.3