-
Notifications
You must be signed in to change notification settings - Fork 244
/
addon_delete.go
51 lines (45 loc) · 958 Bytes
/
addon_delete.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
50
51
package main
import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/mitchellh/cli"
"strings"
)
type AddonDelete struct {
Meta
}
func (c *AddonDelete) Help() string {
helpText := `
pd addon delete <ID> Delete details of an addon
` + c.Meta.Help()
return strings.TrimSpace(helpText)
}
func (c *AddonDelete) Synopsis() string {
return "Delete details of an addon"
}
func AddonDeleteCommand() (cli.Command, error) {
return &AddonDelete{}, nil
}
func (c *AddonDelete) Run(args []string) int {
flags := c.Meta.FlagSet("addon delete")
flags.Usage = func() { fmt.Println(c.Help()) }
if err := flags.Parse(args); err != nil {
log.Error(err)
return -1
}
if err := c.Meta.Setup(); err != nil {
log.Error(err)
return -1
}
client := c.Meta.Client()
if len(flags.Args()) != 1 {
log.Error("Please specify addon id")
return -1
}
err := client.DeleteAddon(flags.Arg(0))
if err != nil {
log.Error(err)
return -1
}
return 0
}