Skip to content

fix: confirm when deleting template #2866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jul 11, 2022
Next Next commit
prompt for confirmation before deleting templates (#2830)
  • Loading branch information
ketang committed Jul 8, 2022
commit 5b51ea3241ac0efbc6b87055375e6389e633db50
11 changes: 11 additions & 0 deletions cli/templatedelete.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cli

import (
"fmt"
"strings"

"github.com/spf13/cobra"
"golang.org/x/xerrors"
Expand Down Expand Up @@ -70,6 +71,16 @@ func templateDelete() *cobra.Command {
templates = append(templates, template)
}

// Confirm deletion of the template.
_, err = cliui.Prompt(cmd, cliui.PromptOptions{
Text: fmt.Sprintf("Delete these templates: %s?", cliui.Styles.Code.Render(strings.Join(templateNames, ", "))),
IsConfirm: true,
Default: "no",
})
if err != nil {
return err
}

for _, template := range templates {
err := client.DeleteTemplate(ctx, template.ID)
if err != nil {
Expand Down