From 3236f3ec316057447424526236a7295f739f5364 Mon Sep 17 00:00:00 2001 From: LinuxBoy-96 <128245725+LinuxBoy-96@users.noreply.github.com> Date: Tue, 25 Mar 2025 11:10:47 -0400 Subject: [PATCH] chore: switch from lexopt to clap_lex --- Cargo.lock | 14 +++++++------- Cargo.toml | 2 +- src/main.rs | 18 ++++++++++-------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5afa467..6204b67 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -869,6 +869,12 @@ dependencies = [ "libc", ] +[[package]] +name = "clap_lex" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" + [[package]] name = "clipboard-win" version = "5.4.0" @@ -1152,6 +1158,7 @@ name = "cosmic-greeter" version = "0.1.0" dependencies = [ "chrono", + "clap_lex", "cosmic-bg-config", "cosmic-comp-config", "cosmic-config", @@ -1165,7 +1172,6 @@ dependencies = [ "greetd_ipc", "i18n-embed", "i18n-embed-fl", - "lexopt", "libcosmic", "log", "logind-zbus", @@ -3195,12 +3201,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" -[[package]] -name = "lexopt" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baff4b617f7df3d896f97fe922b64817f6cd9a756bb81d40f8883f2f66dcb401" - [[package]] name = "libc" version = "0.2.171" diff --git a/Cargo.toml b/Cargo.toml index 5e64fef..0a6ed54 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ upower_dbus = { git = "https://github.com/pop-os/dbus-settings-bindings", rev = # Required for some features zbus = { workspace = true, optional = true } # CLI arguments -lexopt = "0.3.0" +clap_lex = "0.7" # Internationalization i18n-embed = { version = "0.14", features = [ "fluent-system", diff --git a/src/main.rs b/src/main.rs index 0d3bb8c..5468d7c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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> { - let mut parser = Parser::from_env(); +fn main() -> Result<(), Box> { + 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"# ); } +