tci/src/cfg.rs
alemi 7e1fd5fe3e
feat: made it way simpler
no .tci dir! no .tci.toml! just one tci script, keep your scripts in
your repo and start them from .tci with bash tasks, instead of
reinventing the wheel with configs and conditions i should pre-parse as
many info as possible and provide to the underlying .tci script
2024-02-15 04:12:41 +01:00

23 lines
489 B
Rust

#[derive(Debug, Default, serde::Deserialize)]
pub struct TciConfig {
#[serde(default)]
pub allow_all: bool,
#[serde(default)]
pub branch: Option<String>,
#[serde(default)]
pub hooks: Vec<String>,
}
impl TciConfig {
pub fn load() -> Result<Self, toml::de::Error> {
let config_path = std::env::var("TCI_CONFIG")
.unwrap_or_else(|_| "/etc/tci/config.toml".into());
let cfg_raw = std::fs::read_to_string(config_path)
.unwrap_or_default();
toml::from_str(&cfg_raw)
}
}