summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-04-24 19:00:04 +0200
committerfxqnlr <[email protected]>2023-04-24 19:00:04 +0200
commit96d400ca1275bf8444e5ad4dc6c8a06b01c3ea9d (patch)
tree740e6f16b78cfe9c8a1019580bef0de1a3491300 /src/commands
parent99c84b5a81f395f4f094b157019e84bfc4459df6 (diff)
downloadmodlist-96d400ca1275bf8444e5ad4dc6c8a06b01c3ea9d.tar
modlist-96d400ca1275bf8444e5ad4dc6c8a06b01c3ea9d.tar.gz
modlist-96d400ca1275bf8444e5ad4dc6c8a06b01c3ea9d.zip
add auto create dirs, database and default config
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/download.rs2
-rw-r--r--src/commands/mod.rs2
-rw-r--r--src/commands/setup.rs70
3 files changed, 1 insertions, 73 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs
index 9434591..1a8eb8f 100644
--- a/src/commands/download.rs
+++ b/src/commands/download.rs
@@ -23,7 +23,7 @@ pub async fn download(config: Cfg, all_lists: bool, clean: bool, delete_old: boo
23 23
24 for current_list in liststack { 24 for current_list in liststack {
25 let downloaded_versions = get_downloaded_versions(current_list.clone())?; 25 let downloaded_versions = get_downloaded_versions(current_list.clone())?;
26 println!("To download: {:#?}", downloaded_versions); 26 // println!("To download: {:#?}", downloaded_versions);
27 let current_version_ids = match userlist_get_all_current_versions_with_mods( 27 let current_version_ids = match userlist_get_all_current_versions_with_mods(
28 config.clone(), 28 config.clone(),
29 String::from(&current_list.id), 29 String::from(&current_list.id),
diff --git a/src/commands/mod.rs b/src/commands/mod.rs
index 1c7c012..0f13056 100644
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -2,12 +2,10 @@ pub mod download;
2pub mod io; 2pub mod io;
3pub mod list; 3pub mod list;
4pub mod modification; 4pub mod modification;
5pub mod setup;
6pub mod update; 5pub mod update;
7 6
8pub use download::*; 7pub use download::*;
9pub use io::*; 8pub use io::*;
10pub use list::*; 9pub use list::*;
11pub use modification::*; 10pub use modification::*;
12pub use setup::*;
13pub use update::*; 11pub use update::*;
diff --git a/src/commands/setup.rs b/src/commands/setup.rs
deleted file mode 100644
index 34da2f8..0000000
--- a/src/commands/setup.rs
+++ /dev/null
@@ -1,70 +0,0 @@
1use std::{fs::File, path::Path};
2
3use crate::{config::Cfg, db::db_setup, error::MLE};
4
5pub async fn setup(config: Cfg) -> MLE<()> {
6 let db_file = format!("{}/data.db", config.data);
7
8 if !Path::new(&db_file).exists() {
9 create(config, db_file)?;
10 }
11
12 /*
13 match s_config_get_version(config.clone()) {
14 Ok(ver) => {
15 match ver.as_str() {
16 "0.2" => to_03(config)?,
17 "0.3" => to_04(config)?,
18 _ => return Err(MLError::new(ErrorType::Other, "UNKNOWN_VERSION"))
19 }
20 },
21 Err(..) => to_02(config).await?
22 };
23 */
24
25 Ok(())
26}
27
28fn create(config: Cfg, db_file: String) -> MLE<()> {
29 println!("Create database");
30
31 File::create(db_file)?;
32 db_setup(config)?;
33 Ok(())
34}
35
36//async fn to_02(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
37// let lists = lists_get_all_ids(config.clone())?;
38//
39// for list in lists {
40// println!("Updating {}", list);
41// s_insert_column(config.clone(), String::from(&list), String::from("current_download"), String::from("TEXT"), None)?;
42//
43// let full_list = lists_get(config.clone(), String::from(&list))?;
44//
45// let versions = userlist_get_all_current_version_ids(config.clone(), full_list.clone().id)?;
46//
47// let raw_versions = get_raw_versions(String::from(&config.apis.modrinth), versions).await;
48//
49// for ver in raw_versions {
50// println!("Adding link for {}", ver.project_id);
51// let file = ver.files.into_iter().find(|f| f.primary).unwrap();
52// s_userlist_update_download(config.clone(), String::from(&full_list.id), ver.project_id, file.url)?;
53// }
54// };
55// s_config_create_version(config)?;
56//
57// Ok(())
58//}
59//
60//fn to_03(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
61// s_insert_column(config.clone(), String::from("lists"), String::from("download_folder"), String::from("TEXT"), None)?;
62// s_config_update_version(config, String::from("0.3"))
63//}
64//
65//fn to_04(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
66// for list_id in lists_get_all_ids(config.clone())? {
67// s_insert_column(config.clone(), list_id, String::from("disabled_versions"), String::from("TEXT"), Some(String::from("NONE")))?;
68// }
69// s_config_update_version(config, String::from("0.4"))
70//}