From 2841625b153d193ab23b79d26970f16afa72ef88 Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Sun, 23 Jul 2023 20:05:26 -0700 Subject: [PATCH] handle invalid argument --- src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 955d540..1e962a5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,7 @@ mod color; use color::Color; use libc::{c_int, c_void}; +use std::process; const VERSION: &str = "2.0.0"; @@ -16,12 +17,18 @@ extern "C" { pub extern "C" fn rust_main() { println!("Hello from rust"); - let args = args::parse_arguments().unwrap(); + let args = match args::parse_arguments() { + Ok(args) => args, + Err(e) => { + println!("{e}"); + process::exit(1); + } + }; println!("{:?}", args); if args.version { println!("nms version {VERSION}"); - std::process::exit(0); + process::exit(0); } if let Some(color) = args.foreground {