summaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorfxqnlr <[email protected]>2023-04-20 15:13:58 +0200
committerfxqnlr <[email protected]>2023-04-20 15:13:58 +0200
commit8050cfcd70a16273cc2814fe29c8ee08320d85d3 (patch)
tree13924a7f1a9a0c7515beb47a14fe62d5c387d09a /src/config.rs
parentfde646a876cc43857a278ef09250263a21d547ee (diff)
downloadmodlist-8050cfcd70a16273cc2814fe29c8ee08320d85d3.tar
modlist-8050cfcd70a16273cc2814fe29c8ee08320d85d3.tar.gz
modlist-8050cfcd70a16273cc2814fe29c8ee08320d85d3.zip
cargo fmt
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/config.rs b/src/config.rs
index 075d884..1b54d5f 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,8 +1,11 @@
1use std::{fs::File, io::{Read, Write}}; 1use std::{
2 fs::File,
3 io::{Read, Write},
4};
2 5
3use serde::{Serialize, Deserialize}; 6use serde::{Deserialize, Serialize};
4 7
5use crate::{error::MLE, devdir}; 8use crate::{devdir, error::MLE};
6 9
7#[derive(Debug, Clone, Serialize, Deserialize)] 10#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Cfg { 11pub struct Cfg {
@@ -24,7 +27,12 @@ impl Cfg {
24 Err(err) => { 27 Err(err) => {
25 if err.kind() == std::io::ErrorKind::NotFound { 28 if err.kind() == std::io::ErrorKind::NotFound {
26 println!("No config file found, creating one"); 29 println!("No config file found, creating one");
27 let default_cfg = Cfg { data: String::from("./"), apis: Apis { modrinth: String::from("https://api.modrinth.com/v2/") } }; 30 let default_cfg = Cfg {
31 data: String::from("./"),
32 apis: Apis {
33 modrinth: String::from("https://api.modrinth.com/v2/"),
34 },
35 };
28 let mut file = File::create(devdir(configfile.to_str().unwrap()))?; 36 let mut file = File::create(devdir(configfile.to_str().unwrap()))?;
29 println!("Created config file"); 37 println!("Created config file");
30 file.write_all(toml::to_string(&default_cfg)?.as_bytes())?; 38 file.write_all(toml::to_string(&default_cfg)?.as_bytes())?;