From d6415cf0e03dbb42c573a597d07ea1be5cd1fc44 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 9 May 2023 20:53:34 +0200 Subject: added list check on default change --- src/commands/list.rs | 8 +++++--- src/commands/update.rs | 2 -- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src/commands') diff --git a/src/commands/list.rs b/src/commands/list.rs index 13176f4..8ec662d 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -2,9 +2,9 @@ use crate::{ config::Cfg, db::{ config_change_current_list, config_get_current_list, lists_get, lists_insert, lists_remove, - lists_version, + lists_version, lists_get_all_ids, }, - error::MLE, + error::{MLE, MLError, ErrorType}, update, Modloader, }; @@ -32,7 +32,9 @@ pub fn list_add( } pub fn list_change(config: Cfg, id: String) -> MLE<()> { - //TODO check if list exists + if lists_get_all_ids(config.clone())?.into_iter().find(|l| l == &id).is_none() { + return Err(MLError::new(ErrorType::ArgumentError, "List not found")); + }; println!("Change default list to: {}", id); config_change_current_list(config, id) } diff --git a/src/commands/update.rs b/src/commands/update.rs index d76ba4b..1fe664e 100644 --- a/src/commands/update.rs +++ b/src/commands/update.rs @@ -105,7 +105,6 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String) -> ML } let mut current: Vec = vec![]; - //TODO Split clean and no match if clean || (versions.join("|") != userlist_get_applicable_versions( @@ -134,7 +133,6 @@ 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() -- cgit v1.2.3