2023-11-29 13:04:38 +01:00
|
|
|
use config::{Config, ConfigError, File};
|
|
|
|
use home;
|
|
|
|
use serde_derive::Deserialize;
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
#[allow(unused)]
|
2023-11-29 15:53:47 +01:00
|
|
|
pub struct Cloudlog {
|
|
|
|
pub url: String,
|
|
|
|
pub key: String,
|
|
|
|
pub identifier: String,
|
2023-11-29 13:04:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
#[allow(unused)]
|
2023-11-29 15:53:47 +01:00
|
|
|
pub struct Flrig {
|
|
|
|
pub host: String,
|
|
|
|
pub port: String,
|
2023-11-29 13:04:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug, Deserialize)]
|
|
|
|
#[allow(unused)]
|
|
|
|
pub struct Settings {
|
2023-11-29 15:53:47 +01:00
|
|
|
pub cloudlog: Cloudlog,
|
2023-11-29 13:04:38 +01:00
|
|
|
flrig: Flrig,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Settings {
|
|
|
|
pub fn new() -> Result<Self, ConfigError> {
|
|
|
|
let mut config_file = home::home_dir().unwrap().into_os_string();
|
|
|
|
config_file.push("/.config/clrigctl.toml");
|
|
|
|
|
|
|
|
let settings = Config::builder()
|
|
|
|
.add_source(File::with_name(config_file.to_str().unwrap()))
|
|
|
|
.build()?;
|
|
|
|
|
|
|
|
settings.try_deserialize()
|
|
|
|
}
|
|
|
|
}
|