From 1890d59428dfcca861ea1b7820411d80cc60d713 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Sun, 22 Jan 2023 22:34:17 +0100 Subject: Added list version cmd, fixed some todos --- src/commands/list.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src/commands/list.rs') diff --git a/src/commands/list.rs b/src/commands/list.rs index bc58787..eaf6fa1 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -1,4 +1,4 @@ -use crate::{db::{lists_insert, lists_remove, config_change_current_list, config_get_current_list, lists_get}, Modloader, config::Cfg, input::{Input, ListOptions}, /*cmd_update,*/ error::MLE, /*modrinth::MCVersionType*/}; +use crate::{db::{lists_insert, lists_remove, config_change_current_list, config_get_current_list, lists_get, lists_version}, Modloader, config::Cfg, input::{Input, ListOptions}, cmd_update, error::MLE}; #[derive(Debug, Clone, PartialEq, Eq)] pub struct List { @@ -20,13 +20,9 @@ pub async fn list(config: Cfg, input: Input) -> MLE<()> { ListOptions::Remove => { remove(config, input) }, - /* - Subcmd::Version => { - match version(config, Some(input.args.ok_or("NO_VERSION")?), Some(MCVersionType::Release)).await { - Ok(..) => Ok(()), - Err(e) => Err(Box::new(e)) - } - }*/ + ListOptions::Version => { + version(config, input).await + } } } @@ -44,7 +40,7 @@ fn add(config: Cfg, input: Input) -> MLE<()> { } fn change(config: Cfg, input: Input) -> MLE<()> { - //TODO reimplement current list + println!("Change default list to: {}", input.clone().list.unwrap().id); config_change_current_list(config, input.list.unwrap().id) } @@ -52,17 +48,19 @@ fn remove(config: Cfg, input: Input) -> MLE<()> { lists_remove(config, input.list.unwrap().id) } -/* ///Changing the current lists version and updating it /// #Arguments /// /// * `config` - The current config /// * `args` - All args, to extract the new version -async fn version(config: Cfg, args: Option>, version_type: Option) -> MLE<()> { - let current_list = lists_get(config.clone(), config_get_current_list(config.clone())?)?; +async fn version(config: Cfg, input: Input) -> MLE<()> { + println!("Change version for list {} to minecraft version: {}", input.clone().list.unwrap().id, input.clone().list_mcversion.unwrap()); - lists_version(config.clone(), String::from(¤t_list.id), String::from(&args.unwrap()[0]))?; - //update the list & with -- args - cmd_update(config, vec![current_list], true, true, false).await + lists_version(config.clone(), input.clone().list.ok_or("").unwrap().id, input.clone().list_mcversion.ok_or("").unwrap())?; + + //Linebreak readability + println!(""); + + println!("Check for updates for new minecraft version in list {}", input.clone().list.unwrap().id); + cmd_update(config, vec![input.list.ok_or("").unwrap()], true, input.direct_download, input.delete_old).await } -*/ -- cgit v1.2.3