forked from rexray/rexray
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmds_00_other.go
89 lines (76 loc) · 1.93 KB
/
cmds_00_other.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package cli
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/codedellemc/rexray/util"
)
var (
installFunc func()
uninstallFunc func(bool)
initConfigFlagsFunc func(*CLI)
)
func init() {
initCmdFuncs = append(initCmdFuncs, func(c *CLI) {
c.initOtherCmds()
c.initOtherFlags()
})
}
func (c *CLI) initOtherCmds() {
c.versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version",
Run: func(cmd *cobra.Command, args []string) {
util.PrintVersion(os.Stdout)
},
}
c.c.AddCommand(c.versionCmd)
c.envCmd = &cobra.Command{
Use: "env",
Short: "Print the REX-Ray environment",
Run: func(cmd *cobra.Command, args []string) {
evs := c.config.EnvVars()
for _, ev := range evs {
fmt.Println(ev)
}
},
}
c.c.AddCommand(c.envCmd)
c.installCmd = &cobra.Command{
Use: "install",
Short: "Install REX-Ray",
Run: func(cmd *cobra.Command, args []string) {
if installFunc != nil {
installSelfCert(c.ctx, c.config)
installFunc()
}
},
}
c.c.AddCommand(c.installCmd)
c.uninstallCmd = &cobra.Command{
Use: "uninstall",
Short: "Uninstall REX-Ray",
Run: func(cmd *cobra.Command, args []string) {
if uninstallFunc != nil {
pkgManager, _ := cmd.Flags().GetBool("package")
uninstallFunc(pkgManager)
}
},
}
c.c.AddCommand(c.uninstallCmd)
}
func (c *CLI) initOtherFlags() {
c.c.PersistentFlags().BoolP("help", "?", false,
"Help about the current command")
c.c.PersistentFlags().StringVarP(&c.cfgFile, "config", "c", "",
"The path to a custom REX-Ray configuration file")
c.c.PersistentFlags().BoolP(
"verbose", "v", false, "Print verbose help information")
//c.c.PersistentFlags().StringVarP(&c.service, "service", "s", "",
// "The name of the libStorage service")
if initConfigFlagsFunc != nil {
initConfigFlagsFunc(c)
}
c.uninstallCmd.Flags().Bool("package", false,
"A flag indicating a package manager is performing the uninstallation")
}