github.com/koron/hk@v0.0.0-20150303213137-b8aeaa3ab34c/destroy.go (about) 1 package main 2 3 import ( 4 "fmt" 5 "log" 6 "os" 7 "os/exec" 8 ) 9 10 var cmdDestroy = &Command{ 11 Run: runDestroy, 12 Usage: "destroy <name>", 13 Category: "app", 14 Short: "destroy an app", 15 Long: ` 16 Destroy destroys a heroku app. There is no going back, so be 17 sure you mean it. The command will prompt for confirmation, or 18 accept confirmation via stdin. 19 20 Example: 21 22 $ hk destroy myapp 23 warning: This will destroy myapp and its add-ons. Please type "myapp" to continue: 24 Destroyed myapp. 25 26 $ echo myapp | hk destroy myapp 27 Destroyed myapp. 28 `, 29 } 30 31 func runDestroy(cmd *Command, args []string) { 32 if len(args) != 1 { 33 cmd.PrintUsage() 34 os.Exit(2) 35 } 36 appname := args[0] 37 38 warning := fmt.Sprintf("This will destroy %s and its add-ons. Please type %q to continue:", appname, appname) 39 mustConfirm(warning, appname) 40 41 must(client.AppDelete(appname)) 42 log.Printf("Destroyed %s.", appname) 43 remotes, _ := gitRemotes() 44 for remote, remoteApp := range remotes { 45 if appname == remoteApp { 46 exec.Command("git", "remote", "rm", remote).Run() 47 } 48 } 49 }