-
Notifications
You must be signed in to change notification settings - Fork 31
/
cli_test_handler.go
54 lines (49 loc) · 1.34 KB
/
cli_test_handler.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
package main
import (
"strings"
"github.com/urfave/cli"
)
func getTestCommand(config *Config) cli.Command {
return cli.Command{
Action: getTestAction(config),
Aliases: []string{"t"},
Description: "run tests in live-reload mode",
Flags: getTestFlags(),
Name: "test",
Usage: "run tests in live-reload mode",
}
}
func getTestFlags() []cli.Flag {
return []cli.Flag{
getFlagBuildOutput(),
getFlagCommandsDelimiter(),
getFlagEnvVars(),
getFlagFileExtensions(),
getFlagIgnoredNames(),
getFlagRate(),
getFlagSilent(),
getFlagSuperVerboseLogs(),
getFlagVerboseLogs(),
getFlagWatchDirectory(),
getFlagWorkDirectory(),
}
}
func getTestAction(config *Config) cli.ActionFunc {
return func(c *cli.Context) error {
config.RunTest = true
config.BuildOutput = c.String("output")
config.CommandsDelimiter = c.String("exec-delim")
config.EnvVars = c.StringSlice("env")
config.FileExtensions = strings.Split(c.String("exts"), ",")
config.IgnoredNames = strings.Split(c.String("ignore"), ",")
config.Rate = c.Duration("rate")
config.WatchDirectory = c.String("watch")
config.WorkDirectory = c.String("dir")
config.assignDefaults()
config.LogSilent = c.Bool("silent")
config.LogVerbose = c.Bool("verbose")
config.LogSuperVerbose = c.Bool("vverbose")
config.interpretLogLevel()
return nil
}
}