/
tester.go
47 lines (37 loc) · 1010 Bytes
/
tester.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
package cmd
import (
"github.com/jukylin/esim/pkg"
"github.com/jukylin/esim/tool/tester"
"github.com/spf13/cobra"
)
var testerCmd = &cobra.Command{
Use: "test",
Short: "自动运行go test 命令",
Long: `
监听文件修改,捕获事件并在当前项目下执行go test命令
`,
Run: func(cmd *cobra.Command, args []string) {
watcher := tester.NewFsnotifyWatcher(
tester.WithFwLogger(logger),
)
execer := pkg.NewCmdExec(
pkg.WithCmdExecLogger(logger),
)
ter := tester.NewTester(
tester.WithTesterLogger(logger),
tester.WithTesterWatcher(watcher),
tester.WithTesterExec(execer),
)
ter.Run(v)
},
}
func init() {
rootCmd.AddCommand(testerCmd)
testerCmd.Flags().BoolP(pkg.WireCmd, "w", true, "运行wire 命令")
testerCmd.Flags().BoolP(pkg.MockeryCmd, "", true, "运行mockery 命令")
testerCmd.Flags().BoolP(pkg.LintCmd, "", false, "运行 golangci-lint 命令")
err := v.BindPFlags(testerCmd.Flags())
if err != nil {
logger.Errorf(err.Error())
}
}