summaryrefslogtreecommitdiff
path: root/src/commands/modification.rs
diff options
context:
space:
mode:
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}