bee-san / Ares

Automated decoding of encrypted text without knowing the key or ciphers used
MIT License
575 stars 28 forks source link

[BUG] Patch for handling no input #342

Open emmatebibyte opened 9 months ago

emmatebibyte commented 9 months ago
diff --git a/src/cli/mod.rs b/src/cli/mod.rs
index b28d59d..021a4d7 100644
--- a/src/cli/mod.rs
+++ b/src/cli/mod.rs
@@ -69,8 +69,10 @@ pub fn parse_cli_args() -> (String, Config) {
     let input_text: String = if opts.file.is_some() {
         read_and_parse_file(opts.file.unwrap())
     } else {
-        opts.text
-            .expect("Error. No input was provided. Please use ares --help")
+        opts.text.unwrap_or_else(|| {
+            eprintln!("Error. No input was provided. Please use ares --help");
+            std::process::exit(1);
+        })
     };

     // Fixes bug where opts.text and opts.file are partially borrowed