src/app/config/config.rs

6f8b64c4fa1b89868a2dbaa1bbd9fda20ecd0768
youtube-tui/src/app/config/config.rs history · blame · raw

37 lines · 690 bytes

 1use std::error::Error;
 2
 3use super::{commands::CommandsConfig, MainConfig};
 4
 5#[derive(Clone, Debug)]
 6pub struct Config {
 7    pub commands: CommandsConfig,
 8    pub main: MainConfig,
 9}
10
11impl Default for Config {
12    fn default() -> Self {
13        Self {
14            commands: CommandsConfig::default(),
15            main: MainConfig::default(),
16        }
17    }
18}
19
20impl Config {
21    pub fn load() -> Result<Self, Box<dyn Error>> {
22        Ok(Self {
23            main: MainConfig::load()?,
24            commands: CommandsConfig::load()?,
25        })
26    }
27}
28
29pub struct EnvVar {
30    pub url: Option<String>,
31}
32
33impl Default for EnvVar {
34    fn default() -> Self {
35        Self { url: None }
36    }
37}