use self::dirs::config_path;
use serde::{Deserialize, Serialize};
use std::fs;
pub mod dirs;
pub const DIALTONE_CONFIG_FILE: &str = "dialtone.toml";
#[derive(Serialize, Deserialize, Debug)]
pub struct DialtoneConfig {
pub default_acct: Option<String>,
}
impl DialtoneConfig {
pub fn from_config_dir() -> Self {
let path = config_path(DIALTONE_CONFIG_FILE);
let contents = fs::read_to_string(path).unwrap();
toml::from_str(&contents).unwrap()
}
pub fn to_toml_string(&self) -> String {
toml::to_string_pretty(self).unwrap()
}
}
impl Default for DialtoneConfig {
fn default() -> Self {
Self { default_acct: Default::default() }
}
}