diff options
author | fxqnlr <[email protected]> | 2022-12-28 13:15:10 +0100 |
---|---|---|
committer | fxqnlr <[email protected]> | 2022-12-28 13:15:10 +0100 |
commit | 5326d48f6e0a88ad42005c39b73f7baaf91c9b86 (patch) | |
tree | 154ff8715a2e0f121b285870d52c50f1737f7abc /src/commands/io.rs | |
parent | e1c79889d3bf02c8d131d642fed8ba7ef9521bf4 (diff) | |
download | modlist-5326d48f6e0a88ad42005c39b73f7baaf91c9b86.tar modlist-5326d48f6e0a88ad42005c39b73f7baaf91c9b86.tar.gz modlist-5326d48f6e0a88ad42005c39b73f7baaf91c9b86.zip |
added devdir; better config dir
Diffstat (limited to 'src/commands/io.rs')
-rw-r--r-- | src/commands/io.rs | 8 |
1 files changed, 5 insertions, 3 deletions
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; | |||
2 | use std::io::prelude::*; | 2 | use std::io::prelude::*; |
3 | use serde::{Serialize, Deserialize}; | 3 | use serde::{Serialize, Deserialize}; |
4 | 4 | ||
5 | use crate::{input::{Input, Subcmd}, db::{lists_get, userlist_get_all_ids, lists_get_all_ids, lists_insert}, config::Cfg, Modloader, mod_add, List}; | 5 | 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}; |
6 | 6 | ||
7 | #[derive(Debug, Serialize, Deserialize)] | 7 | #[derive(Debug, Serialize, Deserialize)] |
8 | struct Export { | 8 | struct 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)?; |