cfg
This commit is contained in:
parent
ab8461b6df
commit
32b1272ff6
22
src/config.rs
Normal file
22
src/config.rs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
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);
|
||||||
|
return cfg;
|
||||||
|
}
|
||||||
|
DEFAULT
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn save(config_path: PathBuf, config: Config) {
|
||||||
|
fs::write(config_path, serde_json::to_string(&config).unwrap()).unwrap();
|
||||||
|
}
|
@ -12,3 +12,10 @@ pub struct Game<'a> {
|
|||||||
pub references: Vec<&'a str>,
|
pub references: Vec<&'a str>,
|
||||||
pub app_id: u32,
|
pub app_id: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(serde::Deserialize, serde::Serialize)]
|
||||||
|
pub struct Config {
|
||||||
|
pub update_only: bool,
|
||||||
|
pub skip_self_update: bool,
|
||||||
|
pub bonus_content: bool,
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user