Prevent --slot from being used with --list-all
This commit is contained in:
@@ -18,6 +18,7 @@ pub enum Error {
|
|||||||
SlotHasNoIdentity(RetiredSlotId),
|
SlotHasNoIdentity(RetiredSlotId),
|
||||||
SlotIsNotEmpty(RetiredSlotId),
|
SlotIsNotEmpty(RetiredSlotId),
|
||||||
TimedOut,
|
TimedOut,
|
||||||
|
UseListForSingleSlot,
|
||||||
YubiKey(yubikey_piv::Error),
|
YubiKey(yubikey_piv::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,6 +86,9 @@ impl fmt::Debug for Error {
|
|||||||
Error::TimedOut => {
|
Error::TimedOut => {
|
||||||
writeln!(f, "Timed out while waiting for a YubiKey to be inserted.")?
|
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 {
|
Error::YubiKey(e) => match e {
|
||||||
yubikey_piv::error::Error::NotFound => {
|
yubikey_piv::error::Error::NotFound => {
|
||||||
writeln!(f, "Please insert the YubiKey you want to set up")?
|
writeln!(f, "Please insert the YubiKey you want to set up")?
|
||||||
|
|||||||
@@ -271,6 +271,10 @@ fn identity(flags: PluginFlags) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn list(flags: PluginFlags, all: bool) -> 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| {
|
print_details("recipients", flags, all, |_, recipient, metadata| {
|
||||||
println!("{}", metadata);
|
println!("{}", metadata);
|
||||||
println!("{}", recipient.to_string());
|
println!("{}", recipient.to_string());
|
||||||
|
|||||||
Reference in New Issue
Block a user