aboutsummaryrefslogtreecommitdiff
path: root/nitrocli/src/args.rs
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-01-15 23:53:59 +0000
committerDaniel Mueller <deso@posteo.net>2019-01-26 23:35:08 -0800
commit274ae17ca0fc86ebfcbaa3a6cb4201e2cfd0f622 (patch)
tree97ed6f39f1351bc5c614de3c68e0ec112c84ba17 /nitrocli/src/args.rs
parenteabca4c9612ae24911cca2ea1917f5c0fb2df9e9 (diff)
downloadnitrocli-274ae17ca0fc86ebfcbaa3a6cb4201e2cfd0f622.tar.gz
nitrocli-274ae17ca0fc86ebfcbaa3a6cb4201e2cfd0f622.tar.bz2
Add the -V/--version option
The -V/--version option prints the nitrocli version to stdout and exits. In the future, it should also print the used libnitrokey version, but as the required function is only available with nitrokey 0.3.2 and as the current interface does not reflect the latest change in version naming, I skipped that in this patch.
Diffstat (limited to 'nitrocli/src/args.rs')
-rw-r--r--nitrocli/src/args.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
index 0fed3be..3b89bf1 100644
--- a/nitrocli/src/args.rs
+++ b/nitrocli/src/args.rs
@@ -844,6 +844,11 @@ fn parse_arguments<'io, 'ctx: 'io>(
let cmd_help = cmd_help!(command);
let mut subargs = vec![];
let mut parser = argparse::ArgumentParser::new();
+ parser.add_option(
+ &["-V", "--version"],
+ argparse::Print(format!("nitrocli {}", env!("CARGO_PKG_VERSION"))),
+ "Print version information and exit",
+ );
let _ = parser.refer(&mut verbosity).add_option(
&["-v", "--verbose"],
argparse::IncrBy::<u64>(1),