From 5adcfae31efadde81c08532ef23e5101626bf3c5 Mon Sep 17 00:00:00 2001 From: FroVolod Date: Sun, 11 Aug 2024 13:32:59 +0300 Subject: [PATCH] fix: Require at least one access key to be selected in interactive mode when deleting a key (#385) Resolves #383 If no access key is entered: ![Screenshot 2024-08-11 at 12 08 07](https://github.com/user-attachments/assets/b7af6d1e-3c86-4b01-b0d9-f7a038a32207) --- .../account/delete_key/public_keys_to_delete.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/commands/account/delete_key/public_keys_to_delete.rs b/src/commands/account/delete_key/public_keys_to_delete.rs index 77a72f35f..d1c4b28a1 100644 --- a/src/commands/account/delete_key/public_keys_to_delete.rs +++ b/src/commands/account/delete_key/public_keys_to_delete.rs @@ -145,6 +145,19 @@ impl PublicKeyList { access_key_list, ) .with_formatter(formatter) + .with_validator( + |list: &[inquire::list_option::ListOption<&AccessKeyInfo>]| { + if list.is_empty() { + Ok(inquire::validator::Validation::Invalid( + inquire::validator::ErrorMessage::Custom( + "At least one key must be selected (use space to select)".to_string(), + ), + )) + } else { + Ok(inquire::validator::Validation::Valid) + } + }, + ) .prompt()? .iter() .map(|access_key_info| access_key_info.public_key.clone())