Skip to main content

Grove/Binary/
mod.rs

1//! Binary Module
2//!
3//! Contains binary-specific initialization and build logic.
4//! Used by the standalone Grove executable.
5
6pub mod Build;
7pub mod Main;
8
9/// Binary configuration
10#[derive(Debug, Clone)]
11pub struct BinaryConfig {
12	/// Binary name
13	pub name:String,
14	/// Binary version
15	pub version:String,
16	/// Enable verbose output
17	pub verbose:bool,
18	/// Enable debug mode
19	pub debug:bool,
20}
21
22impl BinaryConfig {
23	/// Create a new binary configuration
24	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	/// Set verbose mode
34	pub fn with_verbose(mut self, verbose:bool) -> Self {
35		self.verbose = verbose;
36		self
37	}
38
39	/// Set debug mode
40	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}