handle invalid argument

This commit is contained in:
Greg Shuflin 2023-07-23 20:05:26 -07:00
parent 4f74c2f8cd
commit 2841625b15

View File

@ -3,6 +3,7 @@ mod color;
use color::Color; use color::Color;
use libc::{c_int, c_void}; use libc::{c_int, c_void};
use std::process;
const VERSION: &str = "2.0.0"; const VERSION: &str = "2.0.0";
@ -16,12 +17,18 @@ extern "C" {
pub extern "C" fn rust_main() { pub extern "C" fn rust_main() {
println!("Hello from rust"); 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); println!("{:?}", args);
if args.version { if args.version {
println!("nms version {VERSION}"); println!("nms version {VERSION}");
std::process::exit(0); process::exit(0);
} }
if let Some(color) = args.foreground { if let Some(color) = args.foreground {