summaryrefslogtreecommitdiff
path: root/src/commands/modification.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2022-11-04 23:41:21 +0100
committerfxqnlr <[email protected]>2022-11-04 23:41:21 +0100
commit5d50f446a1a4612c0c931bdbc61f945760392f29 (patch)
tree44414994e19b41979a8a939b120ada0d1aa8a13a /src/commands/modification.rs
parent96cc5257de09682df345e768dc2a91303f9b36c9 (diff)
downloadmodlist-5d50f446a1a4612c0c931bdbc61f945760392f29.tar
modlist-5d50f446a1a4612c0c931bdbc61f945760392f29.tar.gz
modlist-5d50f446a1a4612c0c931bdbc61f945760392f29.zip
"finished" update, added some tests
Diffstat (limited to 'src/commands/modification.rs')
-rw-r--r--src/commands/modification.rs11
1 files changed, 1 insertions, 10 deletions
diff --git a/src/commands/modification.rs b/src/commands/modification.rs
index 43e2180..b90c82c 100644
--- a/src/commands/modification.rs
+++ b/src/commands/modification.rs
@@ -1,6 +1,6 @@
1use std::io::{Error, ErrorKind}; 1use std::io::{Error, ErrorKind};
2 2
3use crate::{modrinth::{project, versions, Version}, config::Cfg, db::{insert_mod, remove_mod_from_list, get_mod_id, insert_mod_in_list, get_mods, get_mods_from_list}, input::Input, get_current_list}; 3use crate::{modrinth::{project, versions, extract_current_version}, config::Cfg, db::{insert_mod, remove_mod_from_list, get_mod_id, insert_mod_in_list, get_mods, get_mods_from_list}, input::Input, get_current_list};
4 4
5pub async fn modification(config: Cfg, args: Option<Vec<String>>) -> Result<(), Box<dyn std::error::Error>> { 5pub async fn modification(config: Cfg, args: Option<Vec<String>>) -> Result<(), Box<dyn std::error::Error>> {
6 6
@@ -77,12 +77,3 @@ fn remove(config: Cfg, args: Vec<String>) -> Result<(), Box<dyn std::error::Erro
77 Ok(()) => Ok(()), 77 Ok(()) => Ok(()),
78 } 78 }
79} 79}
80
81fn extract_current_version(versions: Vec<Version>) -> Result<String, Box<dyn std::error::Error>> {
82 match versions.len() {
83 0 => Err(Box::new(Error::new(ErrorKind::NotFound, "NO_VERSIONS_AVAILABLE"))),
84 //TODO compare publish dates
85 1.. => Ok(versions[0].id.to_string()),
86 _ => panic!("available_versions should never be negative"),
87 }
88}