From fbd1a57839d8bbaaa3da2be0195c8016f8da4ada Mon Sep 17 00:00:00 2001 From: Rita Zerrizuela Date: Fri, 9 Apr 2021 19:39:55 -0300 Subject: [PATCH] Ask for confirmation before deleting a rule (#244) --- internal/cli/rules.go | 7 +++++++ internal/display/rules.go | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/cli/rules.go b/internal/cli/rules.go index e604450c6..d81c3f858 100644 --- a/internal/cli/rules.go +++ b/internal/cli/rules.go @@ -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" ) @@ -246,6 +247,12 @@ auth0 rules delete `, } } + 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) diff --git a/internal/display/rules.go b/internal/display/rules.go index 271ec1b20..19d3a044e 100644 --- a/internal/display/rules.go +++ b/internal/display/rules.go @@ -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 {