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 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/commands/list.rs') 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) } -- cgit v1.2.3