diff options
author | fxqnlr <[email protected]> | 2022-11-04 23:41:21 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-11-04 23:41:21 +0100 |
commit | 5d50f446a1a4612c0c931bdbc61f945760392f29 (patch) | |
tree | 44414994e19b41979a8a939b120ada0d1aa8a13a /src/commands/modification.rs | |
parent | 96cc5257de09682df345e768dc2a91303f9b36c9 (diff) | |
download | modlist-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.rs | 11 |
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 @@ | |||
1 | use std::io::{Error, ErrorKind}; | 1 | use std::io::{Error, ErrorKind}; |
2 | 2 | ||
3 | use 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}; | 3 | use 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 | ||
5 | pub async fn modification(config: Cfg, args: Option<Vec<String>>) -> Result<(), Box<dyn std::error::Error>> { | 5 | pub 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 | |||
81 | fn 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 | } | ||