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/io.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/commands/io.rs') 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)?; -- cgit v1.2.3