chore: switch from lexopt to clap_lex

This commit is contained in:
LinuxBoy-96 2025-03-25 11:10:47 -04:00 committed by GitHub
parent f826b8cce8
commit 3236f3ec31
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 16 deletions

View file

@ -2,20 +2,21 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic_greeter::{greeter, locker};
use clap_lex::RawArgs;
use std::error::Error;
use lexopt::{Arg, Parser};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut parser = Parser::from_env();
fn main() -> Result<(), Box<dyn Error>> {
let raw_args = RawArgs::from_args();
let mut cursor = raw_args.cursor();
// Parse the arguments
while let Some(arg) = parser.next()? {
match arg {
Arg::Short('h') | Arg::Long("help") => {
while let Some(arg) = raw_args.next_os(&mut cursor) {
match arg.to_str() {
Some("--help") | Some("-h") => {
print_help(env!("CARGO_PKG_VERSION"), env!("VERGEN_GIT_SHA"));
return Ok(());
}
Arg::Short('v') | Arg::Long("version") => {
Some("--version") | Some("-v") => {
println!(
"cosmic-greeter {} (git commit {})",
env!("CARGO_PKG_VERSION"),
@ -51,3 +52,4 @@ Options:
-v, --version Show the version of cosmic-greeter"#
);
}