use crate::{Paths, TakoyakiError};
use serde::{Deserialize, Serialize};
use std::fs::read_to_string;
#[derive(Debug, Serialize, Deserialize)]
pub struct Config {
pub unicode: Unicode,
pub colors: serde_yaml::Value,
pub cache: CacheConfig,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Unicode {
pub character: String,
pub paint_bg: bool,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct CacheConfig {
pub interval: i64,
}
impl Config {
pub fn new() -> Result<Self, TakoyakiError> {
let path = Paths::get_config_path();
let raw = read_to_string(path)?;
Ok(serde_yaml::from_str(&raw)?)
}
}