From 274ae17ca0fc86ebfcbaa3a6cb4201e2cfd0f622 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 15 Jan 2019 23:53:59 +0000 Subject: 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. --- nitrocli/CHANGELOG.md | 5 +++++ nitrocli/doc/nitrocli.1 | 4 ++++ nitrocli/doc/nitrocli.1.pdf | Bin 17202 -> 17334 bytes nitrocli/src/args.rs | 5 +++++ 4 files changed, 14 insertions(+) diff --git a/nitrocli/CHANGELOG.md b/nitrocli/CHANGELOG.md index 546315b..9eb8f17 100644 --- a/nitrocli/CHANGELOG.md +++ b/nitrocli/CHANGELOG.md @@ -1,3 +1,8 @@ +Unreleased +---------- +- Added the `-V`/`--version` option to print the program's version + + 0.2.3 ----- - Added the `storage hidden` subcommand for working with hidden volumes diff --git a/nitrocli/doc/nitrocli.1 b/nitrocli/doc/nitrocli.1 index 21dbc3b..74fd635 100644 --- a/nitrocli/doc/nitrocli.1 +++ b/nitrocli/doc/nitrocli.1 @@ -4,6 +4,7 @@ nitrocli \- access Nitrokey devices .SH SYNOPSIS .B nitrocli [\fB\-m\fR|\fB\-\-model pro\fR|\fBstorage\fR] \fR[\fB\-v\fR|\fB\-\-verbose\fR] +[\fB\-V\fR|\fB\-\-version\fR] \fIcommand\fR [\fIarguments\fR] .SH DESCRIPTION @@ -25,6 +26,9 @@ supplied multiple times. A single occurrence will show additional warnings. Commands sent to the device will be shown when supplied three times and full device communication is available with four occurrences. Supplying this option five times enables the highest verbosity. +.TP +\fB\-V\fR, \fB\-\-version\fR +Print the nitrocli version and exit. .SH COMMANDS .SS General .TP diff --git a/nitrocli/doc/nitrocli.1.pdf b/nitrocli/doc/nitrocli.1.pdf index d85e599..32cf085 100644 Binary files a/nitrocli/doc/nitrocli.1.pdf and b/nitrocli/doc/nitrocli.1.pdf differ 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::(1), -- cgit v1.2.3