From 9f49c0724005d8f7aa1a827f199f8e907d893ce4 Mon Sep 17 00:00:00 2001 From: CherretGit Date: Sat, 14 Feb 2026 15:12:32 +0700 Subject: [PATCH] add nfqws2 version command, remove module version command --- rust/crates/zaprett/build.rs | 6 ++++-- rust/crates/zaprett/src/cli.rs | 2 +- rust/crates/zaprett/src/cli/commands.rs | 16 ++++++++-------- rust/crates/zaprett/src/lib.rs | 17 ++++------------- 4 files changed, 17 insertions(+), 24 deletions(-) diff --git a/rust/crates/zaprett/build.rs b/rust/crates/zaprett/build.rs index 2726f5f..018d8be 100644 --- a/rust/crates/zaprett/build.rs +++ b/rust/crates/zaprett/build.rs @@ -1,5 +1,7 @@ use std::env; fn main() { - let zapret_version = env::var("ZAPRET_VERSION").unwrap_or("unknown".to_string()); - println!("cargo:rustc-env=ZAPRET_VERSION={}", zapret_version); + let nfqws_version = env::var("NFQWS_VERSION").unwrap_or("unknown".to_string()); + let nfqws2_version = env::var("NFQWS2_VERSION").unwrap_or("unknown".to_string()); + println!("cargo:rustc-env=NFQWS_VERSION={}", nfqws_version); + println!("cargo:rustc-env=NFQWS2_VERSION={}", nfqws2_version) } diff --git a/rust/crates/zaprett/src/cli.rs b/rust/crates/zaprett/src/cli.rs index 797bf16..ddae220 100644 --- a/rust/crates/zaprett/src/cli.rs +++ b/rust/crates/zaprett/src/cli.rs @@ -5,7 +5,7 @@ use commands::Command; use getset::Getters; #[derive(Parser, Getters)] -// #[command(version)] +#[command(version)] #[getset(get = "pub")] pub struct CliApp { #[command(subcommand)] diff --git a/rust/crates/zaprett/src/cli/commands.rs b/rust/crates/zaprett/src/cli/commands.rs index c64212b..2d054e9 100644 --- a/rust/crates/zaprett/src/cli/commands.rs +++ b/rust/crates/zaprett/src/cli/commands.rs @@ -23,14 +23,14 @@ pub enum Command { /// Show whether autostart is enabled GetAutostart, - /// Show the module version - ModuleVersion, + /// Show the nfqws version + NfqwsVersion, - /// Show the nfqws binary version - BinaryVersion, + /// Show the nfqws2 version + Nfqws2Version, /// Run nfqws - Args { + Run { #[arg(allow_hyphen_values=true, trailing_var_arg = true, num_args = 0..)] args: Vec, }, @@ -54,9 +54,9 @@ impl Command { } Command::SetAutostart => set_autostart().await?, Command::GetAutostart => println!("{}", get_autostart()), - Command::ModuleVersion => println!("{}", module_version().await?), - Command::BinaryVersion => println!("{}", bin_version()), - Command::Args { args } => run_nfqws(&args.join(" "))?, + Command::NfqwsVersion => println!("{}", nfqws_version()), + Command::Nfqws2Version => println!("{}", nfqws2_version()) + Command::Run { args } => run_nfqws(&args.join(" "))?, } Ok(()) diff --git a/rust/crates/zaprett/src/lib.rs b/rust/crates/zaprett/src/lib.rs index e915e58..95ac16a 100644 --- a/rust/crates/zaprett/src/lib.rs +++ b/rust/crates/zaprett/src/lib.rs @@ -53,21 +53,12 @@ pub static DEFAULT_STRATEGY_NFQWS2: &str = " /// я всё ещё жду стратегию под nfqws2 "; -async fn module_version() -> anyhow::Result { - let prop = spawn_blocking(|| Ini::load_from_file(MODULE_PATH.join("module.prop"))) - .await??; - - if let Some(props) = prop.section::(None) - && let Some(version) = props.get("version") - { - return Ok(version.into()); - } - - bail!("Failed to get version, prop not found") +fn nfqws_version() -> &'static str { + env!("NFQWS_VERSION") } -fn bin_version() -> &'static str { - env!("ZAPRET_VERSION") +fn nfqws2_version() -> &'static str { + env!("NFQWS2_VERSION") } pub async fn merge_files(