2022-11-05 20:51:18 +01:00
|
|
|
pub trait LoadConfig {
|
|
|
|
fn load() -> Self;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<T: Sized + for<'a> serde::Deserialize<'a>> LoadConfig for T {
|
|
|
|
fn load() -> Self {
|
2024-03-27 02:11:35 +01:00
|
|
|
let path = std::env::args().nth(1)
|
2022-11-05 20:51:18 +01:00
|
|
|
.expect("Call with config.yaml");
|
2024-03-27 02:49:15 +01:00
|
|
|
crate::systemd::status(&format!("Loading config file {path}"));
|
2022-11-05 20:51:18 +01:00
|
|
|
|
|
|
|
let config_file = std::fs::read_to_string(path)
|
|
|
|
.expect("read config");
|
|
|
|
serde_yaml::from_str(&config_file)
|
|
|
|
.expect("parse config")
|
|
|
|
}
|
|
|
|
}
|