From 2abaebd602a528ee86558ee6a20189186499d4f7 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 17 Sep 2020 03:51:34 +0200 Subject: main.rs: Add version command line option --- src/main.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main.rs b/src/main.rs index dd2da1c..c231d90 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,7 @@ fn main() { let mut opts = Options::new(); opts.optflag("h", "help", "print this help menu"); + opts.optflag("V", "version", "show the program version"); let matches = match opts.parse(&args[1..]) { Ok(m) => m, @@ -28,6 +29,11 @@ fn main() { process::exit(exitcode::USAGE); } + if matches.opt_present("V") { + println!("{}", env!("CARGO_PKG_VERSION")); + process::exit(exitcode::OK); + } + let repo = match Repository::open(".") { Ok(r) => r, Err(e) => { -- cgit v1.2.3