diff options
author | fxqnlr <[email protected]> | 2023-04-24 19:00:04 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2023-04-24 19:00:04 +0200 |
commit | 96d400ca1275bf8444e5ad4dc6c8a06b01c3ea9d (patch) | |
tree | 740e6f16b78cfe9c8a1019580bef0de1a3491300 /src/commands | |
parent | 99c84b5a81f395f4f094b157019e84bfc4459df6 (diff) | |
download | modlist-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.rs | 2 | ||||
-rw-r--r-- | src/commands/mod.rs | 2 | ||||
-rw-r--r-- | src/commands/setup.rs | 70 |
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(¤t_list.id), | 29 | String::from(¤t_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; | |||
2 | pub mod io; | 2 | pub mod io; |
3 | pub mod list; | 3 | pub mod list; |
4 | pub mod modification; | 4 | pub mod modification; |
5 | pub mod setup; | ||
6 | pub mod update; | 5 | pub mod update; |
7 | 6 | ||
8 | pub use download::*; | 7 | pub use download::*; |
9 | pub use io::*; | 8 | pub use io::*; |
10 | pub use list::*; | 9 | pub use list::*; |
11 | pub use modification::*; | 10 | pub use modification::*; |
12 | pub use setup::*; | ||
13 | pub use update::*; | 11 | pub 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 @@ | |||
1 | use std::{fs::File, path::Path}; | ||
2 | |||
3 | use crate::{config::Cfg, db::db_setup, error::MLE}; | ||
4 | |||
5 | pub 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 | |||
28 | fn 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 | //} | ||