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// Re-exports for convenience
10pub use Build::{RuntimeBuild, ServiceRegister};
11pub use Main::Entry;
12
13/// Binary configuration
14#[derive(Debug, Clone)]
15pub struct BinaryConfig {
16	/// Binary name
17	pub name:String,
18	/// Binary version
19	pub version:String,
20	/// Enable verbose output
21	pub verbose:bool,
22	/// Enable debug mode
23	pub debug:bool,
24}
25
26impl BinaryConfig {
27	/// Create a new binary configuration
28	pub fn new() -> Self {
29		Self {
30			name:"grove".to_string(),
31			version:env!("CARGO_PKG_VERSION").to_string(),
32			verbose:false,
33			debug:cfg!(debug_assertions),
34		}
35	}
36
37	/// Set verbose mode
38	pub fn with_verbose(mut self, verbose:bool) -> Self {
39		self.verbose = verbose;
40		self
41	}
42
43	/// Set debug mode
44	pub fn with_debug(mut self, debug:bool) -> Self {
45		self.debug = debug;
46		self
47	}
48}
49
50impl Default for BinaryConfig {
51	fn default() -> Self { Self::new() }
52}
53
54#[cfg(test)]
55mod tests {
56	use super::*;
57
58	#[test]
59	fn test_binary_config_default() {
60		let config = BinaryConfig::default();
61		assert_eq!(config.name, "grove");
62		assert!(!config.verbose);
63	}
64
65	#[test]
66	fn test_binary_config_builder() {
67		let config = BinaryConfig::default().with_verbose(true).with_debug(true);
68
69		assert!(config.verbose);
70		assert!(config.debug);
71	}
72}