summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mueller <deso@posteo.net>2020-01-08 10:07:56 -0800
committerDaniel Mueller <deso@posteo.net>2020-01-08 10:07:56 -0800
commit5357d0dd6dbfbb545ee7ddc41ea4527775ca2e4b (patch)
tree7cd17511797133a0fe97f092de19dd1125567544
parent29077fbca88cddf9f6cf4857623c1a50e756c306 (diff)
downloadnitrocli-5357d0dd6dbfbb545ee7ddc41ea4527775ca2e4b.tar.gz
nitrocli-5357d0dd6dbfbb545ee7ddc41ea4527775ca2e4b.tar.bz2
Use symbolic default values where possible
With the switch to using structopt for argument parsing some of the default values have become mere strings, whereas one of our earlier objectives was to have symbolic values where that is possible. As structopt works with symbolic values equally well, this change makes it use those. As a bonus, also list the possible formats for the --format option to the otp set subcommand.
-rw-r--r--src/args.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/args.rs b/src/args.rs
index 5c6ad4c..aeedfe6 100644
--- a/src/args.rs
+++ b/src/args.rs
@@ -287,7 +287,8 @@ Command! {OtpCommand, [
#[derive(Debug, PartialEq, structopt::StructOpt)]
struct OtpClearArgs {
/// The OTP algorithm to use
- #[structopt(short, long, default_value = "totp", possible_values = &OtpAlgorithm::all_str())]
+ #[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
+ possible_values = &OtpAlgorithm::all_str())]
algorithm: OtpAlgorithm,
/// The OTP slot to clear
slot: u8,
@@ -296,7 +297,8 @@ struct OtpClearArgs {
#[derive(Debug, PartialEq, structopt::StructOpt)]
struct OtpGetArgs {
/// The OTP algorithm to use
- #[structopt(short, long, default_value = "totp", possible_values = &OtpAlgorithm::all_str())]
+ #[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
+ possible_values = &OtpAlgorithm::all_str())]
algorithm: OtpAlgorithm,
/// The time to use for TOTP generation (Unix timestamp) [default: system time]
#[structopt(short, long)]
@@ -308,10 +310,12 @@ struct OtpGetArgs {
#[derive(Debug, PartialEq, structopt::StructOpt)]
struct OtpSetArgs {
/// The OTP algorithm to use
- #[structopt(short, long, default_value = "totp", possible_values = &OtpAlgorithm::all_str())]
+ #[structopt(short, long, default_value = OtpAlgorithm::Totp.as_ref(),
+ possible_values = &OtpAlgorithm::all_str())]
algorithm: OtpAlgorithm,
/// The number of digits to use for the one-time password
- #[structopt(short, long, default_value = "6", possible_values = &OtpMode::all_str())]
+ #[structopt(short, long, default_value = OtpMode::SixDigits.as_ref(),
+ possible_values = &OtpMode::all_str())]
digits: OtpMode,
/// The counter value for HOTP
#[structopt(short, long, default_value = "0")]
@@ -320,7 +324,8 @@ struct OtpSetArgs {
#[structopt(short, long, default_value = "30")]
time_window: u16,
/// The format of the secret
- #[structopt(short, long, default_value = "hex")]
+ #[structopt(short, long, default_value = OtpSecretFormat::Hex.as_ref(),
+ possible_values = &OtpSecretFormat::all_str())]
format: OtpSecretFormat,
/// The OTP slot to use
slot: u8,