Skip to content

Commit

Permalink
fix: Require at least one access key to be selected in interactive mo…
Browse files Browse the repository at this point in the history
…de 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)
  • Loading branch information
FroVolod authored Aug 11, 2024
1 parent c343448 commit 5adcfae
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/commands/account/delete_key/public_keys_to_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down

0 comments on commit 5adcfae

Please sign in to comment.