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/download.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/commands/download.rs') diff --git a/src/commands/download.rs b/src/commands/download.rs index 2714630..4baecee 100644 --- a/src/commands/download.rs +++ b/src/commands/download.rs @@ -1,10 +1,10 @@ use crate::{files::{get_downloaded_versions, download_versions, delete_version, disable_version, clean_list_dir}, db::{userlist_get_all_current_versions_with_mods, lists_get_all_ids, lists_get}, modrinth::get_raw_versions, error::{MLE, ErrorType, MLError}}; -use crate::{List, get_current_list, config::Cfg, input::Input}; +use crate::{List, get_current_list, config::Cfg}; -pub async fn download(config: Cfg, input: Input) -> MLE<()> { +pub async fn download(config: Cfg, all_lists: bool, clean: bool, delete_old: bool) -> MLE<()> { let mut liststack: Vec = vec![]; - if input.all_lists { + if all_lists { let list_ids = lists_get_all_ids(config.clone())?; for id in list_ids { liststack.push(lists_get(config.clone(), id)?); @@ -33,7 +33,7 @@ pub async fn download(config: Cfg, input: Input) -> MLE<()> { let current_download = downloaded_versions.get(&mod_id); - if current_download.is_none() || input.clean { + if current_download.is_none() || clean { to_download.push(current_version); } else { let downloaded_version = current_download.ok_or("SOMETHING_HAS_REALLY_GONE_WRONG").unwrap(); @@ -44,7 +44,7 @@ pub async fn download(config: Cfg, input: Input) -> MLE<()> { } } - if input.clean { clean_list_dir(¤t_list)? }; + if clean { clean_list_dir(¤t_list)? }; if !to_download.is_empty() { download_versions(current_list.clone(), config.clone(), get_raw_versions(&config.apis.modrinth, to_download).await).await?; @@ -54,7 +54,7 @@ pub async fn download(config: Cfg, input: Input) -> MLE<()> { if !to_disable.is_empty() { for ver in to_disable { - if input.delete_old { + if delete_old { println!("Deleting version {} for mod {}", ver.1, ver.0); delete_version(current_list.clone(), ver.1)?; } else { -- cgit v1.2.3