Skip to content

Commit 7c3f923

Browse files
committed
clean up prompt logic
1 parent f192601 commit 7c3f923

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

cli/cmd/app_delete.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"github.com/replicatedhq/replicated/cli/print"
77
"github.com/replicatedhq/replicated/pkg/types"
88
"github.com/spf13/cobra"
9-
"os"
109
)
1110

1211
func (r *runners) InitAppDelete(parent *cobra.Command) *cobra.Command {
@@ -82,23 +81,19 @@ func promptConfirmDelete() (string, error) {
8281
Templates: templates,
8382
Default: "",
8483
Validate: func(input string) error {
85-
if input == "no" {
84+
// "no" will exit with a "prompt declined" error, just in case they don't think to ctrl+c
85+
if input == "no" || input == "yes" {
8686
return nil
8787
}
88-
89-
if input != "yes" {
90-
return errors.New(`only "yes" will be accepted`)
91-
}
92-
93-
return nil
88+
return errors.New(`only "yes" will be accepted`)
9489
},
9590
}
9691

9792
for {
9893
result, err := prompt.Run()
9994
if err != nil {
10095
if err == promptui.ErrInterrupt {
101-
os.Exit(-1)
96+
return "", errors.New("interrupted")
10297
}
10398
continue
10499
}

cli/cmd/release_create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func promptForConfirm() (string, error) {
426426
result, err := prompt.Run()
427427
if err != nil {
428428
if err == promptui.ErrInterrupt {
429-
os.Exit(-1)
429+
return "", errors.New("interrupted")
430430
}
431431
continue
432432
}

0 commit comments

Comments
 (0)