argot_cli/read_config/
mod.rs1pub mod json;
2pub mod toml;
3
4#[cfg(test)]
5mod test {
6 use std::collections::HashMap;
7 use crate::{entries, ConfigEntry};
8
9 #[test]
10 fn entries_macro() {
11 let map: HashMap<String, ConfigEntry> = entries! {
12 "quiet" => Flag,
13 "q" => Alias { target: "quiet" },
14 "verbose" => Count,
15 "v" => Alias { target: "verbose" },
16 "dry-run" => Flag,
17 "n" => Alias { target: "dry-run" },
18 "j" => Int { default: 0 },
19 "browser" => Text,
20 "hints" => List,
21 }.unwrap().into_inner();
22
23 let expected = HashMap::from([
24 ("quiet".to_string(), ConfigEntry::Flag),
25 ("q".to_string(), ConfigEntry::Alias { target: "quiet".to_string() }),
26 ("verbose".to_string(), ConfigEntry::Count),
27 ("v".to_string(), ConfigEntry::Alias { target: "verbose".to_string() }),
28 ("dry-run".to_string(), ConfigEntry::Flag),
29 ("n".to_string(), ConfigEntry::Alias { target: "dry-run".to_string() }),
30 ("j".to_string(), ConfigEntry::Int { default: Some(0) }),
31 ("browser".to_string(), ConfigEntry::Text { default: None }),
32 ("hints".to_string(), ConfigEntry::List { sep: None }),
33 ]);
34
35 assert_eq!(map, expected);
36 }
37}