feat: rename cuddle_cli -> cuddle
Some checks failed
continuous-integration/drone/push Build is failing

Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
2023-08-12 21:41:00 +02:00
parent 53b7513ceb
commit 2cd9509fcb
14 changed files with 3 additions and 3 deletions

28
cuddle/src/config.rs Normal file
View File

@@ -0,0 +1,28 @@
use envconfig::Envconfig;
pub enum CuddleFetchPolicy {
Always,
Once,
Never,
}
#[derive(Envconfig, Clone, Debug)]
pub struct CuddleConfig {
#[envconfig(from = "CUDDLE_FETCH_POLICY", default = "once")]
fetch_policy: String,
}
impl CuddleConfig {
pub fn from_env() -> anyhow::Result<Self> {
CuddleConfig::init_from_env().map_err(|e| anyhow::Error::from(e))
}
pub fn get_fetch_policy(&self) -> anyhow::Result<CuddleFetchPolicy> {
match self.fetch_policy.clone().to_lowercase().as_str() {
"always" => Ok(CuddleFetchPolicy::Always),
"once" => Ok(CuddleFetchPolicy::Once),
"never" => Ok(CuddleFetchPolicy::Never),
_ => Err(anyhow::anyhow!("could not parse fetch policy")),
}
}
}