// use color_eyre::Result; use crate::{ f, nextcloud::model::{NextcloudBoardId, NextcloudHostname, NextcloudPassword, NextcloudUsername}, s, trello::types::{ auth::{TrelloApiKey, TrelloApiSecret}, TrelloBoardName, }, Ctx, NAME, }; #[derive(Clone, Debug, derive_more::From, PartialEq, Eq, serde::Deserialize)] pub(crate) struct TrelloConfig { pub(crate) api_key: TrelloApiKey, pub(crate) api_secret: TrelloApiSecret, pub(crate) board_name: TrelloBoardName, } #[derive(Clone, Debug, derive_more::From, PartialEq, Eq, serde::Deserialize)] pub(crate) struct NextcloudConfig { pub(crate) hostname: NextcloudHostname, pub(crate) username: NextcloudUsername, pub(crate) password: NextcloudPassword, pub(crate) board_id: NextcloudBoardId, } #[derive( Clone, Debug, derive_more::From, PartialEq, Eq, derive_more::AsRef, serde::Deserialize, )] pub struct AppConfig { pub(crate) trello: TrelloConfig, pub(crate) nextcloud: NextcloudConfig, } impl AppConfig { pub fn load(ctx: &Ctx) -> Result { let file = ctx.fs.base().join(f!("{NAME}.toml")); let str = ctx.fs.file(&file).reader()?; Ok(toml::from_str(s!(str).as_str())?) } }