summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-04-23 21:47:37 +0200
committerfxqnlr <[email protected]>2023-04-23 21:47:37 +0200
commit3e65975227baa511f570e8223fccda5607cf905e (patch)
treef852fd5cc3b26a004cf7bfab054e86c0d74c4669 /src/commands
parent416f4dc383ff5a1194da3a5532a8e159a4a1dac0 (diff)
downloadmodlist-3e65975227baa511f570e8223fccda5607cf905e.tar
modlist-3e65975227baa511f570e8223fccda5607cf905e.tar.gz
modlist-3e65975227baa511f570e8223fccda5607cf905e.zip
added config argument, remove devdir
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/io.rs5
-rw-r--r--src/commands/setup.rs4
-rw-r--r--src/commands/update.rs98
3 files changed, 52 insertions, 55 deletions
diff --git a/src/commands/io.rs b/src/commands/io.rs
index 7f03eec..82b30ce 100644
--- a/src/commands/io.rs
+++ b/src/commands/io.rs
@@ -5,7 +5,6 @@ use std::io::prelude::*;
5use crate::{ 5use crate::{
6 config::Cfg, 6 config::Cfg,
7 db::{lists_get, lists_get_all_ids, lists_insert, userlist_get_all_ids}, 7 db::{lists_get, lists_get_all_ids, lists_insert, userlist_get_all_ids},
8 devdir,
9 error::MLE, 8 error::MLE,
10 mod_add, IDSelector, List, Modloader, 9 mod_add, IDSelector, List, Modloader,
11}; 10};
@@ -61,9 +60,7 @@ pub fn export(config: Cfg, list: Option<String>) -> MLE<()> {
61 60
62 let filestr = dirs::home_dir().unwrap().join("mlexport.toml"); 61 let filestr = dirs::home_dir().unwrap().join("mlexport.toml");
63 62
64 let mut file = File::create(devdir( 63 let mut file = File::create(filestr.into_os_string().into_string().unwrap().as_str())?;
65 filestr.into_os_string().into_string().unwrap().as_str(),
66 ))?;
67 file.write_all(toml.as_bytes())?; 64 file.write_all(toml.as_bytes())?;
68 65
69 Ok(()) 66 Ok(())
diff --git a/src/commands/setup.rs b/src/commands/setup.rs
index 40e8c0a..34da2f8 100644
--- a/src/commands/setup.rs
+++ b/src/commands/setup.rs
@@ -1,9 +1,9 @@
1use std::{fs::File, path::Path}; 1use std::{fs::File, path::Path};
2 2
3use crate::{config::Cfg, db::db_setup, devdir, error::MLE}; 3use crate::{config::Cfg, db::db_setup, error::MLE};
4 4
5pub async fn setup(config: Cfg) -> MLE<()> { 5pub async fn setup(config: Cfg) -> MLE<()> {
6 let db_file = devdir(format!("{}/data.db", config.data).as_str()); 6 let db_file = format!("{}/data.db", config.data);
7 7
8 if !Path::new(&db_file).exists() { 8 if !Path::new(&db_file).exists() {
9 create(config, db_file)?; 9 create(config, db_file)?;
diff --git a/src/commands/update.rs b/src/commands/update.rs
index 3d9578b..4bc3ac0 100644
--- a/src/commands/update.rs
+++ b/src/commands/update.rs
@@ -156,52 +156,52 @@ async fn specific_update(config: Cfg, clean: bool, list: List, id: String) -> ML
156 Ok(current[0].clone()) 156 Ok(current[0].clone())
157} 157}
158 158
159#[tokio::test] 159// #[tokio::test]
160async fn download_updates_test() { 160// async fn download_updates_test() {
161 use crate::{ 161// use crate::{
162 modrinth::{Hash, Version, VersionFile, VersionType}, 162// modrinth::{Hash, Version, VersionFile, VersionType},
163 List, Modloader, 163// List, Modloader,
164 }; 164// };
165 165//
166 let config = Cfg::init("modlist.toml").unwrap(); 166// let config = Cfg::init().unwrap();
167 let current_list = List { 167// let current_list = List {
168 id: String::from("..."), 168// id: String::from("..."),
169 mc_version: String::from("..."), 169// mc_version: String::from("..."),
170 modloader: Modloader::Fabric, 170// modloader: Modloader::Fabric,
171 download_folder: String::from("./dev/tests/dl"), 171// download_folder: String::from("./dev/tests/dl"),
172 }; 172// };
173 173//
174 let versions = vec![Version { 174// let versions = vec![Version {
175 id: "dEqtGnT9".to_string(), 175// id: "dEqtGnT9".to_string(),
176 project_id: "kYuIpRLv".to_string(), 176// project_id: "kYuIpRLv".to_string(),
177 author_id: "Qnt13hO8".to_string(), 177// author_id: "Qnt13hO8".to_string(),
178 featured: true, 178// featured: true,
179 name: "1.2.2-1.19 - Fabric".to_string(), 179// name: "1.2.2-1.19 - Fabric".to_string(),
180 version_number: "1.2.2-1.19".to_string(), 180// version_number: "1.2.2-1.19".to_string(),
181 changelog: None, 181// changelog: None,
182 date_published: "2022-11-02T17:41:43.072267Z".to_string(), 182// date_published: "2022-11-02T17:41:43.072267Z".to_string(),
183 downloads: 58, 183// downloads: 58,
184 version_type: VersionType::release, 184// version_type: VersionType::release,
185 files: vec![VersionFile { 185// files: vec![VersionFile {
186 hashes: Hash { 186// hashes: Hash {
187 sha1: "fdc6dc39427fc92cc1d7ad8b275b5b83325e712b".to_string(), 187// sha1: "fdc6dc39427fc92cc1d7ad8b275b5b83325e712b".to_string(),
188 sha512: "5b372f00d6e5d6a5ef225c3897826b9f6a2be5506905f7f71b9e939779765b41be6f2a9b029cfc752ad0751d0d2d5f8bb4544408df1363eebdde15641e99a849".to_string() 188// sha512: "5b372f00d6e5d6a5ef225c3897826b9f6a2be5506905f7f71b9e939779765b41be6f2a9b029cfc752ad0751d0d2d5f8bb4544408df1363eebdde15641e99a849".to_string()
189 }, 189// },
190 url: "https://cdn.modrinth.com/data/kYuIpRLv/versions/dEqtGnT9/waveycapes-fabric-1.2.2-mc1.19.2.jar".to_string(), 190// url: "https://cdn.modrinth.com/data/kYuIpRLv/versions/dEqtGnT9/waveycapes-fabric-1.2.2-mc1.19.2.jar".to_string(),
191 filename: "waveycapes-fabric-1.2.2-mc1.19.2.jar".to_string(), 191// filename: "waveycapes-fabric-1.2.2-mc1.19.2.jar".to_string(),
192 primary: true, 192// primary: true,
193 size: 323176 193// size: 323176
194 }], 194// }],
195 game_versions: vec![ 195// game_versions: vec![
196 "1.19".to_string(), 196// "1.19".to_string(),
197 "1.19.1".to_string(), 197// "1.19.1".to_string(),
198 "1.19.2".to_string() 198// "1.19.2".to_string()
199 ], 199// ],
200 loaders: vec![ 200// loaders: vec![
201 "fabric".to_string() 201// "fabric".to_string()
202 ] 202// ]
203 }]; 203// }];
204 assert!(download_versions(current_list, config, versions) 204// assert!(download_versions(current_list, config, versions)
205 .await 205// .await
206 .is_ok()) 206// .is_ok())
207} 207// }