chore: switch from lexopt to clap_lex
This commit is contained in:
parent
f826b8cce8
commit
3236f3ec31
3 changed files with 18 additions and 16 deletions
14
Cargo.lock
generated
14
Cargo.lock
generated
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
18
src/main.rs
18
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<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"#
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue