diff --git a/src/error.rs b/src/error.rs index c71ba65..d0c535d 100644 --- a/src/error.rs +++ b/src/error.rs @@ -18,6 +18,7 @@ pub enum Error { SlotHasNoIdentity(RetiredSlotId), SlotIsNotEmpty(RetiredSlotId), TimedOut, + UseListForSingleSlot, YubiKey(yubikey_piv::Error), } @@ -85,6 +86,9 @@ impl fmt::Debug for Error { Error::TimedOut => { writeln!(f, "Timed out while waiting for a YubiKey to be inserted.")? } + Error::UseListForSingleSlot => { + writeln!(f, "Use --list to print the recipient for a single slot.")? + } Error::YubiKey(e) => match e { yubikey_piv::error::Error::NotFound => { writeln!(f, "Please insert the YubiKey you want to set up")? diff --git a/src/main.rs b/src/main.rs index 3089430..ef320e4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -271,6 +271,10 @@ fn identity(flags: PluginFlags) -> Result<(), Error> { } fn list(flags: PluginFlags, all: bool) -> Result<(), Error> { + if all && flags.slot.is_some() { + return Err(Error::UseListForSingleSlot); + } + print_details("recipients", flags, all, |_, recipient, metadata| { println!("{}", metadata); println!("{}", recipient.to_string());