aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2019-10-13 04:07:07 -0700
committerDaniel Mueller <deso@posteo.net>2019-10-13 04:07:07 -0700
commite09f5d841dd05ca2f1d276ba678ccbc02d0207e5 (patch)
treed44e7c2d99d730d6ee4bbe2b3df28d186017d850
parent4d57ac618124878b06aabaa8f392bc52ec60e6c9 (diff)
downloadnitrocli-e09f5d841dd05ca2f1d276ba678ccbc02d0207e5.tar.gz
nitrocli-e09f5d841dd05ca2f1d276ba678ccbc02d0207e5.tar.bz2
Properly show the default format used in otp set subcommand
The otp set subcommand allows for three different formats in which the user may pass in the secret, with the default being hexadecimal. By convention we convey the default being used in the help text to the respective command, but that default was missing here. To that end, this change makes sure to include the default format being used in corresponding help text.
-rw-r--r--nitrocli/src/args.rs18
1 files changed, 8 insertions, 10 deletions
diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs
index fe35a9e..9f4cae2 100644
--- a/nitrocli/src/args.rs
+++ b/nitrocli/src/args.rs
@@ -624,10 +624,11 @@ pub fn otp_set(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
let mut digits = OtpMode::SixDigits;
let mut counter: u64 = 0;
let mut time_window: u16 = 30;
- let mut secret_format: Option<OtpSecretFormat> = None;
+ let mut secret_format = OtpSecretFormat::Hex;
let fmt_help = format!(
- "The format of the secret ({})",
- fmt_enum!(OtpSecretFormat::all_variants())
+ "The format of the secret ({}, default: {})",
+ fmt_enum!(OtpSecretFormat::all_variants()),
+ secret_format,
);
let mut parser = argparse::ArgumentParser::new();
parser.set_description("Configures a one-time password slot");
@@ -665,15 +666,12 @@ pub fn otp_set(ctx: &mut ExecCtx<'_>, args: Vec<String>) -> Result<()> {
argparse::Store,
"The time window for TOTP (default: 30)",
);
- let _ = parser.refer(&mut secret_format).add_option(
- &["-f", "--format"],
- argparse::StoreOption,
- &fmt_help,
- );
+ let _ =
+ parser
+ .refer(&mut secret_format)
+ .add_option(&["-f", "--format"], argparse::Store, &fmt_help);
parse(ctx, parser, args)?;
- let secret_format = secret_format.unwrap_or(OtpSecretFormat::Hex);
-
let data = nitrokey::OtpSlotData {
number: slot,
name,