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