diff options
author | fx <[email protected]> | 2023-05-13 17:28:00 +0200 |
---|---|---|
committer | fx <[email protected]> | 2023-05-13 17:28:00 +0200 |
commit | 5a2ea0755b29a8811aeeec1c73679c5783082628 (patch) | |
tree | db2aaedda9678465763993eeec15bd20673394e8 /src/commands/list.rs | |
parent | 9063a041f6b2e72f6e4a861c77ac16065dd5378b (diff) | |
parent | 3b9d717ecd61bd2b5c32ec117f38c7d67a109748 (diff) | |
download | modlist-5a2ea0755b29a8811aeeec1c73679c5783082628.tar modlist-5a2ea0755b29a8811aeeec1c73679c5783082628.tar.gz modlist-5a2ea0755b29a8811aeeec1c73679c5783082628.zip |
Merge pull request 'todos' (#5) from todos into master
Reviewed-on: http://raspberrypi.fritz.box:7920/fx/modlist/pulls/5
Diffstat (limited to 'src/commands/list.rs')
-rw-r--r-- | src/commands/list.rs | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/commands/list.rs b/src/commands/list.rs index 13176f4..4aa4306 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs | |||
@@ -2,9 +2,9 @@ use crate::{ | |||
2 | config::Cfg, | 2 | config::Cfg, |
3 | db::{ | 3 | db::{ |
4 | config_change_current_list, config_get_current_list, lists_get, lists_insert, lists_remove, | 4 | config_change_current_list, config_get_current_list, lists_get, lists_insert, lists_remove, |
5 | lists_version, | 5 | lists_version, lists_get_all_ids, |
6 | }, | 6 | }, |
7 | error::MLE, | 7 | error::{MLE, MLError, ErrorType}, |
8 | update, Modloader, | 8 | update, Modloader, |
9 | }; | 9 | }; |
10 | 10 | ||
@@ -32,7 +32,9 @@ pub fn list_add( | |||
32 | } | 32 | } |
33 | 33 | ||
34 | pub fn list_change(config: Cfg, id: String) -> MLE<()> { | 34 | pub fn list_change(config: Cfg, id: String) -> MLE<()> { |
35 | //TODO check if list exists | 35 | if lists_get_all_ids(config.clone())?.into_iter().find(|l| l == &id).is_none() { |
36 | return Err(MLError::new(ErrorType::ArgumentError, "List not found")); | ||
37 | }; | ||
36 | println!("Change default list to: {}", id); | 38 | println!("Change default list to: {}", id); |
37 | config_change_current_list(config, id) | 39 | config_change_current_list(config, id) |
38 | } | 40 | } |
@@ -68,3 +70,12 @@ pub async fn list_version( | |||
68 | let list = lists_get(config.clone(), id)?; | 70 | let list = lists_get(config.clone(), id)?; |
69 | update(config, vec![list], true, download, delete).await | 71 | update(config, vec![list], true, download, delete).await |
70 | } | 72 | } |
73 | |||
74 | pub fn list_list(config: Cfg) -> MLE<()> { | ||
75 | let lists = lists_get_all_ids(config.clone())?; | ||
76 | for list in lists { | ||
77 | let l = lists_get(config.clone(), list)?; | ||
78 | println!("{}: | {} | {}", l.id, l.mc_version, l.modloader) | ||
79 | } | ||
80 | Ok(()) | ||
81 | } | ||