use config values

This commit is contained in:
2023-09-10 17:36:01 +02:00
parent 32b1272ff6
commit 86b0bb1b7a
3 changed files with 28 additions and 15 deletions

View File

@@ -2,19 +2,14 @@ use crate::structs::Config;
use std::{fs, path::PathBuf};
const DEFAULT: Config = Config {
update_only: false,
skip_self_update: false,
bonus_content: false,
};
pub fn load(config_path: PathBuf) -> Config {
if config_path.exists() {
let cfg = fs::read_to_string(&config_path).unwrap();
let cfg: Config = serde_json::from_str(&cfg).unwrap_or(DEFAULT);
let cfg: Config = serde_json::from_str(&cfg).unwrap_or(Config::default());
return cfg;
}
DEFAULT
save(config_path.clone(), Config::default());
Config::default()
}
pub fn save(config_path: PathBuf, config: Config) {