refactor arg handling

main
Zynh0722 2024-01-31 16:29:38 -08:00
parent 33deea91aa
commit 4fbf68563a
1 changed files with 8 additions and 3 deletions

View File

@ -25,16 +25,21 @@ fn become_wm<C: Connection>(conn: &C, screen: &Screen) -> anyhow::Result<()> {
res.map_err(|e| anyhow!(e)) res.map_err(|e| anyhow!(e))
} }
fn main() -> anyhow::Result<()> { fn handle_args() {
let mut args = std::env::args().skip(1); let mut args = std::env::args().skip(1);
if let Some(arg) = args.next() { if let Some(arg) = args.next() {
if arg != "-v" { if arg != "-v" {
return Err(anyhow!("usage: rswm [-v]")); eprintln!("usage: rswm [-v]");
exit(1);
} else { } else {
println!("rswm-{}", env!("CARGO_PKG_VERSION")); println!("rswm-{}", env!("CARGO_PKG_VERSION"));
return Ok(()); exit(0);
} }
} }
}
fn main() -> anyhow::Result<()> {
handle_args();
// TODO: Investigate LC_CTYPE and Locale stuff from dwm // TODO: Investigate LC_CTYPE and Locale stuff from dwm