mirror of
https://github.com/aljazceru/cdk.git
synced 2026-01-18 04:15:36 +01:00
45 lines
971 B
Rust
45 lines
971 B
Rust
//! Cdk mintd lib
|
|
|
|
#[cfg(feature = "cln")]
|
|
use std::path::PathBuf;
|
|
|
|
pub mod cli;
|
|
pub mod config;
|
|
pub mod env_vars;
|
|
pub mod setup;
|
|
|
|
#[cfg(feature = "cln")]
|
|
fn expand_path(path: &str) -> Option<PathBuf> {
|
|
if path.starts_with('~') {
|
|
if let Some(home_dir) = home::home_dir().as_mut() {
|
|
let remainder = &path[2..];
|
|
home_dir.push(remainder);
|
|
let expanded_path = home_dir;
|
|
Some(expanded_path.clone())
|
|
} else {
|
|
None
|
|
}
|
|
} else {
|
|
Some(PathBuf::from(path))
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test {
|
|
use std::env::current_dir;
|
|
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn example_is_parsed() {
|
|
let config = config::Settings::new(Some(format!(
|
|
"{}/example.config.toml",
|
|
current_dir().expect("cwd").to_string_lossy()
|
|
)));
|
|
let cache = config.info.http_cache;
|
|
|
|
assert_eq!(cache.ttl, Some(60));
|
|
assert_eq!(cache.tti, Some(60));
|
|
}
|
|
}
|