cdk_mintd/
lib.rs

1//! Cdk mintd lib
2
3#[cfg(feature = "cln")]
4use std::path::PathBuf;
5
6pub mod cli;
7pub mod config;
8pub mod env_vars;
9pub mod setup;
10
11#[cfg(feature = "cln")]
12fn expand_path(path: &str) -> Option<PathBuf> {
13    if path.starts_with('~') {
14        if let Some(home_dir) = home::home_dir().as_mut() {
15            let remainder = &path[2..];
16            home_dir.push(remainder);
17            let expanded_path = home_dir;
18            Some(expanded_path.clone())
19        } else {
20            None
21        }
22    } else {
23        Some(PathBuf::from(path))
24    }
25}
26
27#[cfg(test)]
28mod test {
29    use std::env::current_dir;
30
31    use super::*;
32
33    #[test]
34    fn example_is_parsed() {
35        let config = config::Settings::new(Some(format!(
36            "{}/example.config.toml",
37            current_dir().expect("cwd").to_string_lossy()
38        )));
39        let cache = config.info.http_cache;
40
41        assert_eq!(cache.ttl, Some(60));
42        assert_eq!(cache.tti, Some(60));
43    }
44}