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 From bfc5c2c68007785b3d58724c0dae355162341866 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 9 May 2023 21:02:23 +0200 Subject: added list for lists --- src/commands/list.rs | 9 +++++++++ src/main.rs | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'src/commands/list.rs') diff --git a/src/commands/list.rs b/src/commands/list.rs index 8ec662d..4aa4306 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -70,3 +70,12 @@ pub async fn list_version( let list = lists_get(config.clone(), id)?; update(config, vec![list], true, download, delete).await } + +pub fn list_list(config: Cfg) -> MLE<()> { + let lists = lists_get_all_ids(config.clone())?; + for list in lists { + let l = lists_get(config.clone(), list)?; + println!("{}: | {} | {}", l.id, l.mc_version, l.modloader) + } + Ok(()) +} diff --git a/src/main.rs b/src/main.rs index 4239dc1..4979386 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use modlist::{ config::Cfg, db::{config_get_current_list, lists_get, lists_get_all_ids}, download, export, get_current_list, import, list_add, list_change, list_remove, list_version, - mod_add, mod_remove, update, IDSelector, List, Modloader, VersionLevel, + mod_add, mod_remove, update, IDSelector, List, Modloader, VersionLevel, list_list, }; #[derive(Parser)] @@ -222,7 +222,7 @@ async fn main() { } ListCommands::Remove { id } => list_remove(config, id), ListCommands::List => { - todo!() + list_list(config) } ListCommands::Change { id } => list_change(config, id), ListCommands::Version { -- cgit v1.2.3