1pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>;
5
6#[derive(Debug, Default)]
8pub struct App {
9 pub config: Config,
11}
12
13#[derive(Debug, Default)]
15pub struct Config {
16 pub verbose: bool,
18}
19
20impl App {
21 pub fn new() -> Self {
23 Self::default()
24 }
25
26 pub fn with_config(config: Config) -> Self {
28 Self { config }
29 }
30
31 pub fn run(&self) -> Result<()> {
33 if self.config.verbose {
34 println!("Running omni-dev in verbose mode");
35 }
36
37 println!("omni-dev is ready!");
38 Ok(())
39 }
40}
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn test_app_creation() {
48 let app = App::new();
49 assert!(!app.config.verbose);
50 }
51
52 #[test]
53 fn test_app_with_config() {
54 let config = Config { verbose: true };
55 let app = App::with_config(config);
56 assert!(app.config.verbose);
57 }
58
59 #[test]
60 fn test_app_run() {
61 let app = App::new();
62 assert!(app.run().is_ok());
63 }
64}