diff options
Diffstat (limited to 'src/apis/modrinth.rs')
-rw-r--r-- | src/apis/modrinth.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/apis/modrinth.rs b/src/apis/modrinth.rs index 9890cf2..36ab5df 100644 --- a/src/apis/modrinth.rs +++ b/src/apis/modrinth.rs | |||
@@ -1,4 +1,3 @@ | |||
1 | use std::io::{Error, ErrorKind}; | ||
2 | use chrono::{DateTime, FixedOffset}; | 1 | use chrono::{DateTime, FixedOffset}; |
3 | use reqwest::Client; | 2 | use reqwest::Client; |
4 | use serde::Deserialize; | 3 | use serde::Deserialize; |
@@ -142,7 +141,7 @@ pub async fn project(api: String, name: &str) -> Project { | |||
142 | } | 141 | } |
143 | 142 | ||
144 | pub async fn projects(api: String, ids: Vec<String>) -> Vec<Project> { | 143 | pub async fn projects(api: String, ids: Vec<String>) -> Vec<Project> { |
145 | println!("Getting versions for all mods from modrinth"); | 144 | println!("\tGet versions from modrinth\n"); |
146 | let all = ids.join(r#"",""#); | 145 | let all = ids.join(r#"",""#); |
147 | let url = format!(r#"projects?ids=["{}"]"#, all); | 146 | let url = format!(r#"projects?ids=["{}"]"#, all); |
148 | 147 | ||
@@ -188,7 +187,7 @@ pub fn extract_current_version(versions: Vec<Version>) -> MLE<String> { | |||
188 | } | 187 | } |
189 | times.sort_by_key(|t| t.1); | 188 | times.sort_by_key(|t| t.1); |
190 | times.reverse(); | 189 | times.reverse(); |
191 | println!("Current Version: {}", times[0].0); | 190 | println!("\t └New current version: {}", times[0].0); |
192 | Ok(times[0].0.to_string()) | 191 | Ok(times[0].0.to_string()) |
193 | }, | 192 | }, |
194 | _ => panic!("available_versions should never be negative"), | 193 | _ => panic!("available_versions should never be negative"), |
@@ -198,6 +197,7 @@ pub fn extract_current_version(versions: Vec<Version>) -> MLE<String> { | |||
198 | pub enum MCVersionType { | 197 | pub enum MCVersionType { |
199 | Release, | 198 | Release, |
200 | Latest, | 199 | Latest, |
200 | Specific, | ||
201 | } | 201 | } |
202 | 202 | ||
203 | #[derive(Debug, Deserialize)] | 203 | #[derive(Debug, Deserialize)] |
@@ -220,6 +220,10 @@ pub async fn get_minecraft_version(api: String, version: MCVersionType) -> Strin | |||
220 | &mc_versions[i] | 220 | &mc_versions[i] |
221 | }, | 221 | }, |
222 | MCVersionType::Latest => &mc_versions[0], | 222 | MCVersionType::Latest => &mc_versions[0], |
223 | MCVersionType::Specific => { | ||
224 | println!("Not inplemented"); | ||
225 | &mc_versions[0] | ||
226 | } | ||
223 | }; | 227 | }; |
224 | String::from(&ver.version) | 228 | String::from(&ver.version) |
225 | } | 229 | } |