summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/download.rs31
-rw-r--r--src/commands/modification.rs2
-rw-r--r--src/commands/update.rs2
3 files changed, 17 insertions, 18 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs
index b0efdc2..421f058 100644
--- a/src/commands/download.rs
+++ b/src/commands/download.rs
@@ -1,9 +1,22 @@
1use crate::{modrinth::Version, files::download_file}; 1use crate::{files::get_downloaded_versions, db::{userlist_get_all_applicable_versions_with_mods, userlist_get_all_current_versions_with_mods}};
2#[allow(unused_imports)] 2#[allow(unused_imports)]
3use crate::{List, get_current_list, config::Cfg, db::userlist_get_all_downloads, input::Input}; 3use crate::{List, get_current_list, config::Cfg, db::userlist_get_all_downloads, input::Input};
4 4
5pub async fn download(_config: Cfg, _input: Input) -> Result<(), Box<dyn std::error::Error>> { 5pub async fn download(config: Cfg, _input: Input) -> Result<(), Box<dyn std::error::Error>> {
6
7 let current_list = get_current_list(config.clone())?;
8
6 println!("NO IMPLEMENTATION FOR DOWNLOAD YET"); 9 println!("NO IMPLEMENTATION FOR DOWNLOAD YET");
10
11 let downloaded_versions = get_downloaded_versions(current_list.clone())?;
12 println!("DL: {:?}", downloaded_versions);
13
14 let current_version_ids = userlist_get_all_current_versions_with_mods(config.clone(), String::from(&current_list.id))?;
15 println!("CU: {:?}", current_version_ids);
16
17 let applicable_version_ids = userlist_get_all_applicable_versions_with_mods(config, current_list.id)?;
18 println!("AP: {:?}", applicable_version_ids);
19
7 /* 20 /*
8 let list = get_current_list(config.clone())?; 21 let list = get_current_list(config.clone())?;
9 22
@@ -34,18 +47,4 @@ async fn download_links(_config: Cfg, _input: Input, _current_list: List, _links
34 Ok(String::new()) 47 Ok(String::new())
35} 48}
36 49
37pub async fn download_versions(current_list: List, versions: Vec<Version>) -> Result<String, Box<dyn std::error::Error>> {
38
39 let dl_path = String::from(&current_list.download_folder);
40
41 for ver in versions {
42 let primary_file = ver.files.into_iter().find(|file| file.primary).unwrap();
43 let mut splitname: Vec<&str> = primary_file.filename.split('.').collect();
44 let extension = splitname.pop().ok_or("NO_FILE_EXTENSION")?;
45 let filename = format!("{}.mr{}.{}", splitname.join("."), ver.id, extension);
46 download_file(primary_file.url, current_list.clone().download_folder, filename).await?;
47 }
48
49 Ok(dl_path)
50}
51 50
diff --git a/src/commands/modification.rs b/src/commands/modification.rs
index f36c8c6..91243fc 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, extract_current_version, Version}, config::Cfg, db::{mods_insert, userlist_remove, mods_get_id, userlist_insert, mods_get_all_ids, userlist_get_all_ids, userlist_get_current_version, lists_get_all_ids, mods_remove}, input::{Input, Subcmd}, get_current_list, download_versions, files::delete_version}; 3use crate::{modrinth::{project, versions, extract_current_version, Version}, config::Cfg, db::{mods_insert, userlist_remove, mods_get_id, userlist_insert, mods_get_all_ids, userlist_get_all_ids, userlist_get_current_version, lists_get_all_ids, mods_remove}, input::{Input, Subcmd}, get_current_list, files::{delete_version, download_versions}};
4 4
5pub async fn modification(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { 5pub async fn modification(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> {
6 6
diff --git a/src/commands/update.rs b/src/commands/update.rs
index bf13319..eeb5a4d 100644
--- a/src/commands/update.rs
+++ b/src/commands/update.rs
@@ -1,6 +1,6 @@
1use std::{io::{Error, ErrorKind}, fs::rename}; 1use std::{io::{Error, ErrorKind}, fs::rename};
2 2
3use crate::{config::Cfg, modrinth::{projects, Project, versions, extract_current_version, Version}, get_current_list, db::{userlist_get_all_ids, mods_get_versions, userlist_get_applicable_versions, userlist_change_versions, lists_get_all_ids, lists_get, userlist_get_current_version, userlist_add_disabled_versions, mods_change_versions}, List, input::Input, files::{get_file_path, delete_version}, download_versions}; 3use crate::{config::Cfg, modrinth::{projects, Project, versions, extract_current_version, Version}, get_current_list, db::{userlist_get_all_ids, mods_get_versions, userlist_get_applicable_versions, userlist_change_versions, lists_get_all_ids, lists_get, userlist_get_current_version, userlist_add_disabled_versions, mods_change_versions}, List, input::Input, files::{get_file_path, delete_version, download_versions}};
4 4
5pub async fn update(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> { 5pub async fn update(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> {
6 6