-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
55 lines (44 loc) · 919 Bytes
/
main.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
package main
import (
"os"
"github.com/spf13/cobra"
"github.com/modularise/modularise/cmd"
"github.com/modularise/modularise/cmd/config"
)
func main() {
var c config.CLIConfig
root := cobra.Command{
Use: "modularise",
PersistentPreRunE: func(_ *cobra.Command, args []string) error {
return c.CheckConfig()
},
SilenceUsage: true,
}
attachGlobalFlags(&root, &c)
root.AddCommand(
checkCmd(&c),
splitCmd(&c),
)
if err := root.Execute(); err != nil {
os.Exit(1)
}
}
func checkCmd(c *config.CLIConfig) *cobra.Command {
check := &cobra.Command{
Use: "check",
RunE: func(_ *cobra.Command, _ []string) error {
return cmd.RunCheck(c)
},
}
return check
}
func splitCmd(c *config.CLIConfig) *cobra.Command {
split := &cobra.Command{
Use: "split",
RunE: func(_ *cobra.Command, _ []string) error {
return cmd.RunSplit(c)
},
}
attachSplitFlags(split, c)
return split
}