diff options
author | fxqnlr <[email protected]> | 2022-11-05 21:53:24 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-11-05 21:53:24 +0100 |
commit | 0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd (patch) | |
tree | 6262c397c500834cf6a06059394ac51328de3aed /src/commands/modification.rs | |
parent | 5d50f446a1a4612c0c931bdbc61f945760392f29 (diff) | |
download | modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.tar.gz modlist-0f5223d3d3f6aeb6bb1a0b09ad3d4ef5731774dd.zip |
added setup & download; direct input
Diffstat (limited to 'src/commands/modification.rs')
-rw-r--r-- | src/commands/modification.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/commands/modification.rs b/src/commands/modification.rs index b90c82c..e877a63 100644 --- a/src/commands/modification.rs +++ b/src/commands/modification.rs | |||
@@ -34,9 +34,12 @@ async fn add(config: Cfg, args: Vec<String>) -> Result<(), Box<dyn std::error::E | |||
34 | if project.versions.is_empty() { panic!("This should never happen"); }; | 34 | if project.versions.is_empty() { panic!("This should never happen"); }; |
35 | 35 | ||
36 | let available_versions = versions(String::from(&config.apis.modrinth), String::from(&project.id), current_list.clone()).await; | 36 | let available_versions = versions(String::from(&config.apis.modrinth), String::from(&project.id), current_list.clone()).await; |
37 | |||
38 | let current_version = extract_current_version(available_versions.clone())?; | ||
39 | 37 | ||
38 | let current_id = extract_current_version(available_versions.clone())?; | ||
39 | |||
40 | let current_version = available_versions.clone().into_iter().find(|v| v.id == current_id).unwrap(); | ||
41 | |||
42 | let file = current_version.files.into_iter().find(|f| f.primary).unwrap().url; | ||
40 | //add to current list and mod table | 43 | //add to current list and mod table |
41 | match get_mods_from_list(config.clone(), current_list.clone()) { | 44 | match get_mods_from_list(config.clone(), current_list.clone()) { |
42 | Ok(mods) => { | 45 | Ok(mods) => { |
@@ -44,10 +47,10 @@ async fn add(config: Cfg, args: Vec<String>) -> Result<(), Box<dyn std::error::E | |||
44 | if mods.contains(&project.id) { | 47 | if mods.contains(&project.id) { |
45 | return Err(Box::new(Error::new(ErrorKind::Other, "MOD_ALREADY_ON_LIST"))); } | 48 | return Err(Box::new(Error::new(ErrorKind::Other, "MOD_ALREADY_ON_LIST"))); } |
46 | else { | 49 | else { |
47 | insert_mod_in_list(config.clone(), current_list.clone(), String::from(&project.id), current_version, available_versions)?; | 50 | insert_mod_in_list(config.clone(), current_list.clone(), String::from(&project.id), current_version.id, available_versions, file)?; |
48 | } | 51 | } |
49 | }, | 52 | }, |
50 | Err(..) => insert_mod_in_list(config.clone(), current_list, String::from(&project.id), current_version, available_versions)?, | 53 | Err(..) => insert_mod_in_list(config.clone(), current_list, String::from(&project.id), current_version.id, available_versions, file)?, |
51 | }; | 54 | }; |
52 | 55 | ||
53 | match get_mods(config.clone()) { | 56 | match get_mods(config.clone()) { |