feat(rm): adds --yes flag to auto-accept all prompts

This commit is contained in:
Lewis Wynne 2026-02-11 17:57:05 +00:00
parent cf7dbf5bee
commit 9130c09e56
4 changed files with 19 additions and 1 deletions

View file

@ -47,6 +47,10 @@ func del(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
yes, err := cmd.Flags().GetBool("yes")
if err != nil {
return err
}
keyPatterns, err := cmd.Flags().GetStringSlice("key")
if err != nil {
return err
@ -72,7 +76,7 @@ func del(cmd *cobra.Command, args []string) error {
byStore := make(map[string]*storeTargets)
var storeOrder []string
for _, target := range targets {
if interactive || config.Key.AlwaysPromptDelete {
if !yes && (interactive || config.Key.AlwaysPromptDelete) {
var confirm string
promptf("remove '%s'? (y/n)", target.display)
if err := scanln(&confirm); err != nil {
@ -120,6 +124,7 @@ func del(cmd *cobra.Command, args []string) error {
func init() {
delCmd.Flags().BoolP("interactive", "i", false, "Prompt yes/no for each deletion")
delCmd.Flags().BoolP("yes", "y", false, "Skip all confirmation prompts")
delCmd.Flags().StringSliceP("key", "k", nil, "Delete keys matching glob pattern (repeatable)")
rootCmd.AddCommand(delCmd)
}