aboutsummaryrefslogtreecommitdiff
path: root/src/config/mod.rs
blob: 1ad8b7bcde0116646f4ee1ce762a87f80cddf844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// SPDX-License-Identifier: MIT
// Copyright (c) 2023 Robin Jarry

mod accounts;
mod columns;
mod style;
mod templates;
mod ui;

use std::collections::HashMap;

use anyhow::Result;
use derivative::Derivative;
use ini::Ini;

pub use crate::config::accounts::{AccountConfig, BackendType};
pub use crate::config::ui::UiConfig;

#[derive(Derivative)]
#[derivative(Debug, Default)]
pub struct Config {
    pub ui: UiConfig,
    pub accounts: HashMap<String, AccountConfig>,
}

impl Config {
    pub fn parse(accounts: Vec<String>) -> Result<Self> {
        let ini = Ini::load_from_file("")?;

        let c = Config {
            ui: UiConfig::parse(&ini)?,
            accounts: HashMap::new(),
        };

        Ok(c)
    }
}