trello-to-deck/src/config.rs

34 lines
695 B
Rust
Raw Normal View History

2024-11-29 19:19:36 +00:00
//
use color_eyre::Result;
use crate::{f, s, Ctx, NAME};
#[derive(Clone, Debug, derive_more::From, PartialEq, Eq, PartialOrd, Ord, serde::Deserialize)]
pub struct TrelloConfig {
pub api_key: String,
pub api_secret: String,
pub board_name: String,
}
2024-11-29 19:19:36 +00:00
#[derive(
Clone,
Debug,
derive_more::From,
PartialEq,
Eq,
PartialOrd,
Ord,
derive_more::AsRef,
serde::Deserialize,
)]
pub struct AppConfig {
pub trello: TrelloConfig,
}
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())?)
}
}