diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2020-09-25 02:06:00 +0200 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2020-10-02 11:54:35 +0200 |
commit | adbfa1c12257405112445497324938a011db8664 (patch) | |
tree | f220284722a7273264d6a7ab4597d9d4b17106af /src/commands.rs | |
parent | 98b69f32755ad480be4d9622084277e08ea2efb9 (diff) | |
download | nitrocli-adbfa1c12257405112445497324938a011db8664.tar.gz nitrocli-adbfa1c12257405112445497324938a011db8664.tar.bz2 |
Update nitrokey to v0.8.0
This patch updates the nitrokey dependency to version 0.8.0 and applies
all breaking changes (Config fields renaming, DeviceWrapper and Model
non-exhaustiveness, changed Display implementation for Model).
Diffstat (limited to 'src/commands.rs')
-rw-r--r-- | src/commands.rs | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/commands.rs b/src/commands.rs index 9685050..c5a3b11 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -370,11 +370,7 @@ fn print_storage_status( } /// Query and pretty print the status that is common to all Nitrokey devices. -fn print_status( - ctx: &mut Context<'_>, - model: &'static str, - device: &nitrokey::DeviceWrapper<'_>, -) -> anyhow::Result<()> { +fn print_status(ctx: &mut Context<'_>, device: &nitrokey::DeviceWrapper<'_>) -> anyhow::Result<()> { let serial_number = device .get_serial_number() .context("Could not query the serial number")?; @@ -387,7 +383,7 @@ fn print_status( firmware version: {fwv} user retry count: {urc} admin retry count: {arc}"#, - model = model, + model = device.get_model(), id = serial_number, fwv = device .get_firmware_version() @@ -416,13 +412,7 @@ fn print_status( /// Inquire the status of the nitrokey. pub fn status(ctx: &mut Context<'_>) -> anyhow::Result<()> { - with_device(ctx, |ctx, device| { - let model = match device { - nitrokey::DeviceWrapper::Pro(_) => "Pro", - nitrokey::DeviceWrapper::Storage(_) => "Storage", - }; - print_status(ctx, model, &device) - }) + with_device(ctx, |ctx, device| print_status(ctx, &device)) } /// List the attached Nitrokey devices. @@ -671,9 +661,9 @@ pub fn config_get(ctx: &mut Context<'_>) -> anyhow::Result<()> { capslock binding: {cl} scrollock binding: {sl} require user PIN for OTP: {otp}"#, - nl = format_option(config.numlock), - cl = format_option(config.capslock), - sl = format_option(config.scrollock), + nl = format_option(config.num_lock), + cl = format_option(config.caps_lock), + sl = format_option(config.scroll_lock), otp = config.user_password, )?; Ok(()) @@ -702,9 +692,9 @@ pub fn config_set(ctx: &mut Context<'_>, args: args::ConfigSetArgs) -> anyhow::R .get_config() .context("Failed to get current configuration")?; let config = nitrokey::Config { - numlock: numlock.or(config.numlock), - capslock: capslock.or(config.capslock), - scrollock: scrollock.or(config.scrollock), + num_lock: numlock.or(config.num_lock), + caps_lock: capslock.or(config.caps_lock), + scroll_lock: scrollock.or(config.scroll_lock), user_password: otp_pin.unwrap_or(config.user_password), }; device |