mirror of
https://github.com/egor-white/zaprett.git
synced 2026-03-22 08:28:20 +05:00
add nfqws2 version command, remove module version command
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)]
|
||||
|
||||
@@ -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<String>,
|
||||
},
|
||||
@@ -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(())
|
||||
|
||||
@@ -53,21 +53,12 @@ pub static DEFAULT_STRATEGY_NFQWS2: &str = "
|
||||
/// я всё ещё жду стратегию под nfqws2
|
||||
";
|
||||
|
||||
async fn module_version() -> anyhow::Result<String> {
|
||||
let prop = spawn_blocking(|| Ini::load_from_file(MODULE_PATH.join("module.prop")))
|
||||
.await??;
|
||||
|
||||
if let Some(props) = prop.section::<String>(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(
|
||||
|
||||
Reference in New Issue
Block a user