use std::{env, sync::Arc};
pub mod agile;
pub mod api;
pub mod error;
#[derive(Default, Clone)]
pub struct Rujira {
pub url: Arc<str>,
pub debug: bool,
pub task_create: bool,
pub token: Arc<str>,
}
impl Rujira {
pub fn new() -> Self {
Self {
url: Arc::from("http://localhost:8080"),
..Default::default()
}
}
pub fn from_env_handler(self) -> Self {
let url = Arc::from(env::var("RUJIRA_URL").unwrap_or("http://localhost:8080".to_string()));
let debug = env::var("RUJIRA_DEBUG")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(false);
let task_create = env::var("RUJIRA_TASK_CREATE")
.ok()
.and_then(|v| v.parse().ok())
.unwrap_or(false);
let token = Arc::from(env::var("RUJIRA_TOKEN").expect("RUJIRA_TOKEN not set"));
Self {
url,
debug,
task_create,
token,
}
}
}
trait Rub {
fn to_static(self) -> &'static str;
}
impl Rub for bool {
fn to_static(self) -> &'static str {
if self {
"true"
} else {
"false"
}
}
}
#[cfg(test)]
mod tests;