Skip to content

Commit

Permalink
Ask for confirmation before deleting a rule (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
Widcket authored Apr 9, 2021
1 parent 55c55d8 commit fbd1a57
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions internal/cli/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/auth0/auth0-cli/internal/ansi"
"github.com/auth0/auth0-cli/internal/auth0"
"github.com/auth0/auth0-cli/internal/prompt"
"github.com/spf13/cobra"
"gopkg.in/auth0.v5/management"
)
Expand Down Expand Up @@ -246,6 +247,12 @@ auth0 rules delete <rule-id>`,
}
}

if !cli.force && canPrompt(cmd) {
if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed {
return nil
}
}

return ansi.Spinner("Deleting Rule", func() error {
_, err := cli.api.Rule.Read(inputs.ID)

Expand Down
2 changes: 1 addition & 1 deletion internal/display/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func (v *ruleView) AsTableHeader() []string {
}

func (v *ruleView) AsTableRow() []string {
return []string{v.ID, v.Name, strconv.FormatBool(v.Enabled), fmt.Sprintf("%d", v.Order)}
return []string{ansi.Faint(v.ID), v.Name, strconv.FormatBool(v.Enabled), fmt.Sprintf("%d", v.Order)}
}

func (v *ruleView) KeyValues() [][]string {
Expand Down

0 comments on commit fbd1a57

Please sign in to comment.