2024-11-29 19:19:36 +00:00
|
|
|
//
|
|
|
|
use color_eyre::Result;
|
|
|
|
|
2024-11-30 11:30:36 +00:00
|
|
|
use crate::{
|
|
|
|
f,
|
|
|
|
nextcloud::model::{NextcloudBoardId, NextcloudHostname, NextcloudPassword, NextcloudUsername},
|
|
|
|
s, Ctx, NAME,
|
|
|
|
};
|
2024-11-29 19:19:36 +00:00
|
|
|
|
2024-11-29 19:19:36 +00:00
|
|
|
#[derive(Clone, Debug, derive_more::From, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
|
2024-11-30 11:30:36 +00:00
|
|
|
pub(crate) struct TrelloConfig {
|
|
|
|
pub(crate) api_key: String,
|
|
|
|
pub(crate) api_secret: String,
|
|
|
|
pub(crate) board_name: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(
|
|
|
|
Clone,
|
|
|
|
Debug,
|
|
|
|
derive_more::From,
|
|
|
|
PartialEq,
|
|
|
|
Eq,
|
|
|
|
PartialOrd,
|
|
|
|
Ord,
|
|
|
|
serde::Deserialize,
|
|
|
|
derive_more::Constructor,
|
|
|
|
)]
|
|
|
|
pub(crate) struct NextcloudConfig {
|
|
|
|
pub(crate) hostname: NextcloudHostname,
|
|
|
|
pub(crate) username: NextcloudUsername,
|
|
|
|
pub(crate) password: NextcloudPassword,
|
|
|
|
pub(crate) board_id: NextcloudBoardId,
|
2024-11-29 19:19:36 +00:00
|
|
|
}
|
|
|
|
|
2024-11-29 19:19:36 +00:00
|
|
|
#[derive(
|
|
|
|
Clone,
|
|
|
|
Debug,
|
|
|
|
derive_more::From,
|
|
|
|
PartialEq,
|
|
|
|
Eq,
|
|
|
|
PartialOrd,
|
|
|
|
Ord,
|
|
|
|
derive_more::AsRef,
|
|
|
|
serde::Deserialize,
|
|
|
|
)]
|
2024-11-29 19:19:36 +00:00
|
|
|
pub struct AppConfig {
|
2024-11-30 11:30:36 +00:00
|
|
|
pub(crate) trello: TrelloConfig,
|
|
|
|
pub(crate) nextcloud: NextcloudConfig,
|
2024-11-29 19:19:36 +00:00
|
|
|
}
|
2024-11-29 19:19:36 +00:00
|
|
|
impl AppConfig {
|
|
|
|
pub fn load(ctx: &Ctx) -> Result<Self> {
|
|
|
|
let file = ctx.fs.base().join(f!("{NAME}.toml"));
|
|
|
|
let str = ctx.fs.file(&file).reader()?;
|
|
|
|
Ok(toml::from_str(s!(str).as_str())?)
|
|
|
|
}
|
|
|
|
}
|