summaryrefslogtreecommitdiff
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/download.rs3
-rw-r--r--src/commands/io.rs8
-rw-r--r--src/commands/setup.rs4
3 files changed, 9 insertions, 6 deletions
diff --git a/src/commands/download.rs b/src/commands/download.rs
index 0f9011c..b958bf3 100644
--- a/src/commands/download.rs
+++ b/src/commands/download.rs
@@ -11,12 +11,13 @@ pub async fn download(config: Cfg, input: Input) -> Result<(), Box<dyn std::erro
11 } 11 }
12 } else { 12 } else {
13 let current = get_current_list(config.clone())?; 13 let current = get_current_list(config.clone())?;
14 println!("Checking for updates of mods in {}", current.id); 14 println!("Downloading current versions of mods in {}", current.id);
15 liststack.push(current) 15 liststack.push(current)
16 } 16 }
17 17
18 for current_list in liststack { 18 for current_list in liststack {
19 let downloaded_versions = get_downloaded_versions(current_list.clone())?; 19 let downloaded_versions = get_downloaded_versions(current_list.clone())?;
20 println!("To download: {:#?}", downloaded_versions);
20 let current_version_ids = userlist_get_all_current_versions_with_mods(config.clone(), String::from(&current_list.id))?; 21 let current_version_ids = userlist_get_all_current_versions_with_mods(config.clone(), String::from(&current_list.id))?;
21 22
22 let mut to_download: Vec<String> = vec![]; 23 let mut to_download: Vec<String> = vec![];
diff --git a/src/commands/io.rs b/src/commands/io.rs
index 2edb95d..39f92d5 100644
--- a/src/commands/io.rs
+++ b/src/commands/io.rs
@@ -2,7 +2,7 @@ use std::fs::File;
2use std::io::prelude::*; 2use std::io::prelude::*;
3use serde::{Serialize, Deserialize}; 3use serde::{Serialize, Deserialize};
4 4
5use crate::{input::{Input, Subcmd}, db::{lists_get, userlist_get_all_ids, lists_get_all_ids, lists_insert}, config::Cfg, Modloader, mod_add, List}; 5use crate::{input::{Input, Subcmd}, db::{lists_get, userlist_get_all_ids, lists_get_all_ids, lists_insert}, config::Cfg, Modloader, mod_add, List, devdir};
6 6
7#[derive(Debug, Serialize, Deserialize)] 7#[derive(Debug, Serialize, Deserialize)]
8struct Export { 8struct Export {
@@ -60,7 +60,9 @@ fn export(config: Cfg, input: Input) -> Result<(), Box<dyn std::error::Error>> {
60 60
61 let toml = toml::to_string( &Export { lists } )?; 61 let toml = toml::to_string( &Export { lists } )?;
62 62
63 let mut file = File::create("export.toml")?; 63 let filestr = dirs::home_dir().unwrap().join("mlexport.toml");
64
65 let mut file = File::create(devdir(filestr.into_os_string().into_string().unwrap().as_str()))?;
64 file.write_all(&toml.as_bytes())?; 66 file.write_all(&toml.as_bytes())?;
65 67
66 Ok(()) 68 Ok(())
@@ -70,7 +72,7 @@ async fn import(config: Cfg, args: Option<Vec<String>>) -> Result<(), Box<dyn st
70 72
71 let filestr: String = match args { 73 let filestr: String = match args {
72 Some(args) => String::from(&args[0]), 74 Some(args) => String::from(&args[0]),
73 None => String::from("export.toml"), 75 None => String::from(devdir(dirs::home_dir().unwrap().join("mlexport.toml").into_os_string().into_string().unwrap().as_str())),
74 }; 76 };
75 77
76 let mut file = File::open(filestr)?; 78 let mut file = File::open(filestr)?;
diff --git a/src/commands/setup.rs b/src/commands/setup.rs
index c7f1bed..e4fa801 100644
--- a/src/commands/setup.rs
+++ b/src/commands/setup.rs
@@ -1,9 +1,9 @@
1use std::{fs::File, path::Path, io::{Error, ErrorKind}}; 1use std::{fs::File, path::Path, io::{Error, ErrorKind}};
2 2
3use crate::{config::Cfg, db::{db_setup, s_config_get_version, s_config_create_version, s_insert_column, lists_get_all_ids, lists_get, userlist_get_all_current_version_ids, s_userlist_update_download, s_config_update_version}, modrinth::get_raw_versions}; 3use crate::{config::Cfg, db::{db_setup, s_config_get_version, s_config_create_version, s_insert_column, lists_get_all_ids, lists_get, userlist_get_all_current_version_ids, s_userlist_update_download, s_config_update_version}, modrinth::get_raw_versions, devdir};
4 4
5pub async fn setup(config: Cfg) -> Result<(), Box<dyn std::error::Error>> { 5pub async fn setup(config: Cfg) -> Result<(), Box<dyn std::error::Error>> {
6 let db_file = format!("{}/data.db", String::from(&config.data)); 6 let db_file = devdir(format!("{}/data.db", config.data).as_str());
7 7
8 if !Path::new(&db_file).exists() { 8 if !Path::new(&db_file).exists() {
9 return create(config, db_file); 9 return create(config, db_file);