Skip to content

Commit

Permalink
Add the -V/--version option
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
robinkrahl authored and d-e-s-o committed Jan 27, 2019
1 parent eabca4c commit 274ae17
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions nitrocli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 4 additions & 0 deletions nitrocli/doc/nitrocli.1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Binary file modified nitrocli/doc/nitrocli.1.pdf
Binary file not shown.
5 changes: 5 additions & 0 deletions nitrocli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 274ae17

Please sign in to comment.