From 3152342dd04201bcc6b66768149127a2f90bd3a1 Mon Sep 17 00:00:00 2001 From: BrettMayson Date: Thu, 26 Jan 2023 01:59:17 -0600 Subject: [PATCH] --version --- Cargo.lock | 2 +- bin/app/Cargo.toml | 2 +- bin/app/src/lib.rs | 19 ++++++++++++++++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 65227888..78dfbbf9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -583,7 +583,7 @@ checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hemtt" -version = "0.10.0" +version = "0.10.0-a16" dependencies = [ "ansi_term", "anyhow", diff --git a/bin/app/Cargo.toml b/bin/app/Cargo.toml index 583aafdd..caa556c0 100644 --- a/bin/app/Cargo.toml +++ b/bin/app/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "hemtt" description = "HEMTT - Arma 3 Build Tool" -version = "0.10.0" +version = "0.10.0-a16" edition = "2021" [dependencies] diff --git a/bin/app/src/lib.rs b/bin/app/src/lib.rs index 950265b5..51d5ab1e 100644 --- a/bin/app/src/lib.rs +++ b/bin/app/src/lib.rs @@ -35,7 +35,7 @@ pub fn cli() -> Command { #[allow(unused_mut)] let mut global = Command::new(env!("CARGO_PKG_NAME")) .about(env!("CARGO_PKG_DESCRIPTION")) - .subcommand_required(true) + .subcommand_required(false) .arg_required_else_help(true) .subcommand(commands::new::cli()) .subcommand(commands::dev::cli()) @@ -54,13 +54,21 @@ pub fn cli() -> Command { .long("threads") .short('t'), ); - global.arg( + global = global.arg( clap::Arg::new("verbosity") .global(true) .help("Verbosity level") .action(ArgAction::Count) .short('v'), - ) + ); + global = global.arg( + clap::Arg::new("version") + .global(false) + .help("Print version") + .action(ArgAction::SetTrue) + .long("version"), + ); + global } /// Run the HEMTT CLI @@ -71,6 +79,11 @@ pub fn cli() -> Command { /// # Panics /// If the number passed to `--threads` is not a valid number pub fn execute(matches: &ArgMatches) -> Result<(), AppError> { + if matches.get_flag("version") { + println!("HEMTT {}", env!("CARGO_PKG_VERSION")); + return Ok(()); + } + logging::init(matches.get_count("verbosity")); trace!("version: {}", env!("CARGO_PKG_VERSION"));