1pub mod Build;
7
8pub mod Main;
9
10#[derive(Debug, Clone)]
12pub struct BinaryConfig {
13 pub name:String,
15
16 pub version:String,
18
19 pub verbose:bool,
21
22 pub debug:bool,
24}
25
26impl BinaryConfig {
27 pub fn new() -> Self {
29 Self {
30 name:"grove".to_string(),
31
32 version:env!("CARGO_PKG_VERSION").to_string(),
33
34 verbose:false,
35
36 debug:cfg!(debug_assertions),
37 }
38 }
39
40 pub fn with_verbose(mut self, verbose:bool) -> Self {
42 self.verbose = verbose;
43
44 self
45 }
46
47 pub fn with_debug(mut self, debug:bool) -> Self {
49 self.debug = debug;
50
51 self
52 }
53}
54
55impl Default for BinaryConfig {
56 fn default() -> Self { Self::new() }
57}
58
59#[cfg(test)]
60mod tests {
61
62 use super::*;
63
64 #[test]
65 fn test_binary_config_default() {
66 let config = BinaryConfig::default();
67
68 assert_eq!(config.name, "grove");
69
70 assert!(!config.verbose);
71 }
72
73 #[test]
74 fn test_binary_config_builder() {
75 let config = BinaryConfig::default().with_verbose(true).with_debug(true);
76
77 assert!(config.verbose);
78
79 assert!(config.debug);
80 }
81}