From 5326d48f6e0a88ad42005c39b73f7baaf91c9b86 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Wed, 28 Dec 2022 13:15:10 +0100 Subject: added devdir; better config dir --- src/commands/download.rs | 3 ++- src/commands/io.rs | 8 +++++--- src/commands/setup.rs | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) (limited to 'src/commands') 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 = 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; use std::io::prelude::*; use serde::{Serialize, Deserialize}; -use crate::{input::{Input, Subcmd}, db::{lists_get, userlist_get_all_ids, lists_get_all_ids, lists_insert}, config::Cfg, Modloader, mod_add, List}; +use crate::{input::{Input, Subcmd}, db::{lists_get, userlist_get_all_ids, lists_get_all_ids, lists_insert}, config::Cfg, Modloader, mod_add, List, devdir}; #[derive(Debug, Serialize, Deserialize)] struct Export { @@ -60,7 +60,9 @@ fn export(config: Cfg, input: Input) -> Result<(), Box> { let toml = toml::to_string( &Export { lists } )?; - let mut file = File::create("export.toml")?; + let filestr = dirs::home_dir().unwrap().join("mlexport.toml"); + + let mut file = File::create(devdir(filestr.into_os_string().into_string().unwrap().as_str()))?; file.write_all(&toml.as_bytes())?; Ok(()) @@ -70,7 +72,7 @@ async fn import(config: Cfg, args: Option>) -> Result<(), Box String::from(&args[0]), - None => String::from("export.toml"), + None => String::from(devdir(dirs::home_dir().unwrap().join("mlexport.toml").into_os_string().into_string().unwrap().as_str())), }; 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 @@ use std::{fs::File, path::Path, io::{Error, ErrorKind}}; -use 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}; +use 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}; pub async fn setup(config: Cfg) -> Result<(), Box> { - let db_file = format!("{}/data.db", String::from(&config.data)); + let db_file = devdir(format!("{}/data.db", config.data).as_str()); if !Path::new(&db_file).exists() { return create(config, db_file); -- cgit v1.2.3