diff options
author | Daniel Mueller <deso@posteo.net> | 2019-01-15 15:26:56 -0800 |
---|---|---|
committer | Daniel Mueller <deso@posteo.net> | 2019-01-15 15:26:56 -0800 |
commit | 984f5fadd1bfcd0184af8bddc4973acfe8affb64 (patch) | |
tree | b2a637f7b261964a949ccc3a2f80970cd39ea7a6 /nitrocli/src/pinentry.rs | |
parent | 74b9b3845846e0fbc2efd37d80b5527be1bee564 (diff) | |
download | nitrocli-984f5fadd1bfcd0184af8bddc4973acfe8affb64.tar.gz nitrocli-984f5fadd1bfcd0184af8bddc4973acfe8affb64.tar.bz2 |
Auto-generate help text for enum-backed optional arguments
This change continues the effort of auto-generating more of the help
text content by extending the logic to optional arguments. We make use
of the fmt_enum macro to format the description of the argument with the
available variants (as well as the default, if any) interpolated.
Diffstat (limited to 'nitrocli/src/pinentry.rs')
-rw-r--r-- | nitrocli/src/pinentry.rs | 23 |
1 files changed, 4 insertions, 19 deletions
diff --git a/nitrocli/src/pinentry.rs b/nitrocli/src/pinentry.rs index 1eecdd0..d6f000c 100644 --- a/nitrocli/src/pinentry.rs +++ b/nitrocli/src/pinentry.rs @@ -26,25 +26,10 @@ use crate::error::Error; /// /// The available PIN types correspond to the PIN types used by the Nitrokey devices: user and /// admin. -#[derive(Clone, Copy, Debug, PartialEq)] -pub enum PinType { - /// The admin PIN. - Admin, - /// The user PIN. - User, -} - -impl str::FromStr for PinType { - type Err = (); - - fn from_str(s: &str) -> Result<Self, Self::Err> { - match s { - "admin" => Ok(PinType::Admin), - "user" => Ok(PinType::User), - _ => Err(()), - } - } -} +Enum! {PinType, [ + Admin => "admin", + User => "user" +]} #[derive(Debug)] pub struct PinEntry { |