]> git.r.bdr.sh - rbdr/blog/blobdiff - src/main.rs
Cleanup
[rbdr/blog] / src / main.rs
index 8867dc08f93337ab31d5aca96ec47be5bc773fb4..535a2dddfc0b7372de01ab85d04f754dd73c5f4e 100644 (file)
@@ -1,4 +1,3 @@
-// mod argument_parser;
 mod configuration;
 mod command;
 mod constants;
@@ -18,6 +17,22 @@ use command::{available_commands, Command, help::Help};
 use configuration::Configuration;
 
 fn main() -> Result<()> {
+    let result = run();
+
+    if cfg!(debug_assertions) {
+        result
+    } else {
+        match result {
+            Ok(_) => Ok(()),
+            Err(e) => {
+                eprintln!("{}", e);
+                std::process::exit(1);
+            }
+        }
+    }
+}
+
+fn run() -> Result<()> {
     let configuration = Configuration::new();
     let commands = available_commands();
     let arguments: Vec<String> = args().collect();