-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcmds.go
More file actions
52 lines (46 loc) · 1.12 KB
/
cmds.go
File metadata and controls
52 lines (46 loc) · 1.12 KB
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
package starter
import (
"fmt"
"github.com/spf13/cobra"
)
func ServiceCommands(s *Starter) []*cobra.Command {
install := &cobra.Command{
Use: "install",
Short: fmt.Sprintf("install service of %s", s.AppName()),
RunE: s.cmdInstall,
}
uninstall := &cobra.Command{
Use: "uninstall",
Short: fmt.Sprintf("uninstall service of %s", s.AppName()),
RunE: s.cmdUnInstall,
}
return []*cobra.Command{install, uninstall}
}
func StdCommands(s *Starter) []*cobra.Command {
serve := &cobra.Command{
Use: "serve",
Short: fmt.Sprintf("run %s in frontend", s.AppName()),
RunE: s.cmdServe,
}
start := &cobra.Command{
Use: "start",
Short: fmt.Sprintf("run %s as daemon", s.AppName()),
RunE: s.cmdStart,
}
stop := &cobra.Command{
Use: "stop",
Short: fmt.Sprintf("stop daemon of %s", s.AppName()),
RunE: s.cmdStop,
}
reload := &cobra.Command{
Use: "reload",
Short: fmt.Sprintf("reload daemon of %s", s.AppName()),
RunE: s.cmdReload,
}
mixed := []*cobra.Command{serve, start, stop, reload}
flags := s.getFlags().Flags()
for _, cmd := range mixed {
AddFlags(cmd, flags)
}
return mixed
}