summaryrefslogblamecommitdiff
path: root/src/config.rs
blob: ad59963da3883474913f304f186ddee72f02715c (plain) (tree)
1
2
3
4
5
6
7
8


                                       
                                    
                
                     
                          
                           


                   
                                    





                                     
                             







                                                         
use config::{Config, File, FileFormat};
use serde::Deserialize;

#[derive(Debug, Clone, Deserialize)]
pub struct Cfg {
    pub data: String,
    pub downloads: String,
    pub clean_remove: bool,
    pub apis: Apis,
}

#[derive(Debug, Clone, Deserialize)]
pub struct Apis {
    pub modrinth: String,
}

impl Cfg {
    pub fn init(path: &str) -> Self {
        //TODO Error Handling
        Config::builder()
            .add_source(File::new(path, FileFormat::Ini))
            .build()
            .unwrap()
            .try_deserialize()
            .unwrap()
    }
}