Skip to content

Commit

Permalink
Merge pull request #1048 from remind101/fix-double-msgs
Browse files Browse the repository at this point in the history
Stop double confirmation messages
  • Loading branch information
ejholmes authored Mar 3, 2017
2 parents 65d9f7a + f61b0c3 commit 59f8001
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions cmd/emp/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

var cmdDestroy = &Command{
Run: maybeMessage(runDestroy),
Run: confirmDestroy(maybeMessage(runDestroy)),
Usage: "destroy <name>",
OptionalMessage: true,
Category: "app",
Expand All @@ -29,13 +29,20 @@ Example:
`,
}

func confirmDestroy(action func(cmd *Command, args []string)) func(cmd *Command, args []string) {
return func(cmd *Command, args []string) {
cmd.AssertNumArgsCorrect(args)

appname := args[0]
warning := fmt.Sprintf("This will destroy %s and its add-ons. Please type %q to continue:", appname, appname)
mustConfirm(warning, appname)
action(cmd, args)
}
}

func runDestroy(cmd *Command, args []string) {
cmd.AssertNumArgsCorrect(args)
appname := args[0]
message := getMessage()

warning := fmt.Sprintf("This will destroy %s and its add-ons. Please type %q to continue:", appname, appname)
mustConfirm(warning, appname)
appname := args[0]

must(client.AppDelete(appname, message))
log.Printf("Destroyed %s.", appname)
Expand Down

0 comments on commit 59f8001

Please sign in to comment.