aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorRuben Beltran del Rio <git@r.bdr.sh>2024-03-09 15:34:57 +0100
committerRuben Beltran del Rio <git@r.bdr.sh>2024-03-09 15:34:57 +0100
commit50f53dc480fda8b3daab7a34454c2dd9f3f5f991 (patch)
tree2205be7a9c806ce59c851de9b50b9e18f973008d /src/main.rs
parent172f4c8807d44ebe38c7f227b7fdc2d6a9dbe323 (diff)
Improve the error handlingrust
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs
index 8867dc0..a5c2cf6 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -18,6 +18,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!("Error: {}", e);
+ std::process::exit(1);
+ }
+ }
+ }
+}
+
+fn run() -> Result<()> {
let configuration = Configuration::new();
let commands = available_commands();
let arguments: Vec<String> = args().collect();