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