src/app/config/config.rs
49 lines · 1215 bytes
1use std::error::Error;
2
3use super::{
4 commands::CommandsConfig, KeybindingsConfig, LayoutsConfigs, MainConfig, PageCommandsConfig,
5};
6use crate::traits::ConfigItem;
7
8#[derive(Clone)]
9pub struct Config {
10 pub commands: CommandsConfig,
11 pub main: MainConfig,
12 pub page_commands: PageCommandsConfig,
13 pub keybindings: KeybindingsConfig,
14 pub layouts: LayoutsConfigs,
15}
16
17impl Default for Config {
18 fn default() -> Self {
19 Self {
20 commands: CommandsConfig::default(),
21 main: MainConfig::default(),
22 page_commands: PageCommandsConfig::default(),
23 keybindings: KeybindingsConfig::default(),
24 layouts: LayoutsConfigs::default(),
25 }
26 }
27}
28
29impl Config {
30 pub fn load() -> Result<Self, Box<dyn Error>> {
31 Ok(Self {
32 main: MainConfig::load()?,
33 commands: CommandsConfig::load()?,
34 page_commands: PageCommandsConfig::load()?,
35 keybindings: KeybindingsConfig::load()?.into(),
36 layouts: LayoutsConfigs::load()?,
37 })
38 }
39}
40
41pub struct EnvVar {
42 pub url: Option<String>,
43}
44
45impl Default for EnvVar {
46 fn default() -> Self {
47 Self { url: None }
48 }
49}