From d7bdc8c1c746782708b127e0df65745d74aff8a6 Mon Sep 17 00:00:00 2001 From: Dennis Ranke Date: Mon, 17 Oct 2022 01:03:01 +0200 Subject: [PATCH] add --version flag to output upkr version --- release/Makefile | 2 +- src/main.rs | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/release/Makefile b/release/Makefile index b786704..f513f96 100644 --- a/release/Makefile +++ b/release/Makefile @@ -1,4 +1,4 @@ -VERSION=0.2.0 +VERSION := $(shell cargo run --release -- --version) all: clean upkr-linux-$(VERSION).tgz upkr-windows-$(VERSION).zip diff --git a/src/main.rs b/src/main.rs index 54f0b6b..5135f42 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,6 +61,10 @@ fn main() -> Result<()> { Short('l') | Long("level") => level = parser.value()?.parse()?, Short(n) if n.is_ascii_digit() => level = n as u8 - b'0', Short('h') | Long("help") => print_help(0), + Long("version") => { + println!("{}", env!("CARGO_PKG_VERSION")); + process::exit(0); + } Long("max-unpacked-size") => max_unpacked_size = parser.value()?.parse()?, Value(val) if infile.is_none() => infile = Some(val.try_into()?), Value(val) if outfile.is_none() => outfile = Some(val.try_into()?), @@ -155,6 +159,8 @@ fn print_help(exit_code: i32) -> ! { eprintln!(" -u, --unpack unpack infile"); eprintln!(" --margin calculate margin for overlapped unpacking of a packed file"); eprintln!(); + eprintln!("Version: {}", env!("CARGO_PKG_VERSION")); + eprintln!(); eprintln!("Config presets for specific unpackers:"); eprintln!(" --z80 --big-endian-bitstream --invert-bit-encoding --simplified-prob-update -9"); eprintln!(