From 1e4807e17344b66ee45b08a7ca2265015685b4ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9ana=20=E6=B1=9F?= Date: Fri, 24 Apr 2026 14:39:01 +0200 Subject: [PATCH] exit gracefully when cli args parsing fails --- src/cli.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 5cd3916..6a3367f 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,7 @@ use std::io::{self, BufRead, BufReader, ErrorKind, Write}; use std::os::unix::net::{UnixListener, UnixStream}; -use std::panic::panic_any; use std::path::Path; +use std::process; use getopts::Options; use winit::event_loop::EventLoopWindowTarget; @@ -255,7 +255,10 @@ pub fn process_cli(args: Vec) -> Result { opts.optflag("v", "version", "print the version of wired and leave"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, - Err(e) => panic_any(e.to_string()), + Err(e) => { + eprintln!("Error: {}", e); + process::exit(1) + } }; // Matching