summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-05-09 20:53:34 +0200
committerfxqnlr <[email protected]>2023-05-09 20:53:34 +0200
commitd6415cf0e03dbb42c573a597d07ea1be5cd1fc44 (patch)
treebe7a6a8694b00e1702481d158638ae7cf3ba78e1
parent9063a041f6b2e72f6e4a861c77ac16065dd5378b (diff)
downloadmodlist-d6415cf0e03dbb42c573a597d07ea1be5cd1fc44.tar
modlist-d6415cf0e03dbb42c573a597d07ea1be5cd1fc44.tar.gz
modlist-d6415cf0e03dbb42c573a597d07ea1be5cd1fc44.zip
added list check on default change
-rw-r--r--src/commands/list.rs8
-rw-r--r--src/commands/update.rs2
-rw-r--r--src/main.rs1
3 files changed, 5 insertions, 6 deletions
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::{
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
34pub fn list_change(config: Cfg, id: String) -> MLE<()> { 34pub 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}
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
105 } 105 }
106 106
107 let mut current: Vec<Version> = vec![]; 107 let mut current: Vec<Version> = vec![];
108 //TODO Split clean and no match
109 if clean 108 if clean
110 || (versions.join("|") 109 || (versions.join("|")
111 != userlist_get_applicable_versions( 110 != userlist_get_applicable_versions(
@@ -134,7 +133,6 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String) -> ML
134 }?; 133 }?;
135 current.push(current_ver.clone()); 134 current.push(current_ver.clone());
136 135
137 //TODO implement version selection if no primary
138 let link = match current_ver 136 let link = match current_ver
139 .files 137 .files
140 .into_iter() 138 .into_iter()
diff --git a/src/main.rs b/src/main.rs
index 2db304b..4239dc1 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,7 +6,6 @@ use modlist::{
6 mod_add, mod_remove, update, IDSelector, List, Modloader, VersionLevel, 6 mod_add, mod_remove, update, IDSelector, List, Modloader, VersionLevel,
7}; 7};
8 8
9//TODO make default list optional
10#[derive(Parser)] 9#[derive(Parser)]
11#[command(author, version, about)] 10#[command(author, version, about)]
12struct Cli { 11struct Cli {