1#![allow(clippy::must_use_candidate)]
9
10use std::path::PathBuf;
11
12use crate::os::dirs as platform;
13
14pub fn harmont_config_dir() -> Option<PathBuf> {
16 platform::home_dir().map(|h| h.join(".harmont"))
17}
18
19pub fn harmont_data_dir() -> Option<PathBuf> {
21 platform::config_dir().map(|c| c.join("harmont"))
22}
23
24pub fn harmont_plugins_dir() -> Option<PathBuf> {
26 harmont_data_dir().map(|d| d.join("plugins"))
27}
28
29pub fn harmont_plugin_state_dir() -> Option<PathBuf> {
31 harmont_data_dir().map(|d| d.join("state"))
32}
33
34#[cfg(test)]
35#[allow(clippy::unwrap_used)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn harmont_config_dir_under_home() {
41 let p = harmont_config_dir().unwrap();
42 assert!(p.ends_with(".harmont"));
43 }
44
45 #[test]
46 fn harmont_data_dir_under_config() {
47 let p = harmont_data_dir().unwrap();
48 assert!(p.ends_with("harmont"));
49 }
50
51 #[test]
52 fn harmont_plugins_dir_resolves() {
53 let p = harmont_plugins_dir().unwrap();
54 assert!(p.ends_with("harmont/plugins"));
55 }
56
57 #[test]
58 fn harmont_plugin_state_dir_resolves() {
59 let p = harmont_plugin_state_dir().unwrap();
60 assert!(p.ends_with("harmont/state"));
61 }
62}