Skip to content

Commit

Permalink
--version
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Jan 26, 2023
1 parent 0eb96a4 commit 3152342
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/app/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
19 changes: 16 additions & 3 deletions bin/app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
Expand All @@ -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"));
Expand Down

0 comments on commit 3152342

Please sign in to comment.