/
delete.go
56 lines (44 loc) · 993 Bytes
/
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
52
53
54
55
56
package ocean
import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
type (
CmdDelete struct {
cmd *cobra.Command
opts CmdDeleteOptions
}
CmdDeleteOptions struct {
*CmdOptions
}
)
func NewCmdDelete(opts *CmdOptions) *cobra.Command {
return newCmdDelete(opts).cmd
}
func newCmdDelete(opts *CmdOptions) *CmdDelete {
var cmd CmdDelete
cmd.cmd = &cobra.Command{
Use: "delete",
Short: "Delete an existing resource",
SilenceErrors: true,
SilenceUsage: true,
}
cmd.opts.Init(cmd.cmd.PersistentFlags(), opts)
cmd.initSubCommands()
return &cmd
}
func (x *CmdDelete) initSubCommands() {
commands := []func(*CmdDeleteOptions) *cobra.Command{
NewCmdDeleteCluster,
NewCmdDeleteLaunchSpec,
}
for _, cmd := range commands {
x.cmd.AddCommand(cmd(&x.opts))
}
}
func (x *CmdDeleteOptions) Init(fs *pflag.FlagSet, opts *CmdOptions) {
x.CmdOptions = opts
}
func (x *CmdDeleteOptions) Validate() error {
return x.CmdOptions.Validate()
}