/
cmds_01_adapter.go
55 lines (48 loc) · 1.29 KB
/
cmds_01_adapter.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
// +build !agent
// +build !controller
package cli
import (
"github.com/spf13/cobra"
)
func init() {
initCmdFuncs = append(initCmdFuncs, func(c *CLI) {
c.initAdapterCmds()
c.initAdapterFlags()
})
}
func (c *CLI) initAdapterCmds() {
c.adapterCmd = &cobra.Command{
Use: "adapter",
Short: "The adapter manager",
PersistentPreRun: c.preRunActivateLibStorage,
Run: func(cmd *cobra.Command, args []string) {
if isHelpFlags(cmd) {
cmd.Usage()
} else {
c.adapterGetTypesCmd.Run(c.adapterGetTypesCmd, args)
}
},
}
c.c.AddCommand(c.adapterCmd)
c.adapterGetTypesCmd = &cobra.Command{
Use: "types",
Short: "List the configured services",
Aliases: []string{"ls", "list"},
Run: func(cmd *cobra.Command, args []string) {
c.mustMarshalOutput(c.r.API().Services(c.ctx))
},
}
c.adapterCmd.AddCommand(c.adapterGetTypesCmd)
c.adapterGetInstancesCmd = &cobra.Command{
Use: "instances",
Short: "List the configured adapter instances",
Run: func(cmd *cobra.Command, args []string) {
c.mustMarshalOutput(c.r.API().Instances(c.ctx))
},
}
c.adapterCmd.AddCommand(c.adapterGetInstancesCmd)
}
func (c *CLI) initAdapterFlags() {
c.addOutputFormatFlag(c.adapterGetTypesCmd.Flags())
c.addOutputFormatFlag(c.adapterGetInstancesCmd.Flags())
}