lib.rs 971 B

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