lib.rs 923 B

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