-
Notifications
You must be signed in to change notification settings - Fork 31
/
cli_default_handler.go
51 lines (47 loc) · 1.32 KB
/
cli_default_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
package main
import (
"strings"
shellquote "github.com/kballard/go-shellquote"
"github.com/urfave/cli"
)
func getDefaultFlags() []cli.Flag {
return []cli.Flag{
getFlagBuildOutput(),
getFlagCommandArguments(),
getFlagCommandsDelimiter(),
getFlagEnvVars(),
getFlagExecGroups(),
getFlagFileExtensions(),
getFlagIgnoredNames(),
getFlagRate(),
getFlagSilent(),
getFlagSuperVerboseLogs(),
getFlagVerboseLogs(),
getFlagWatchDirectory(),
getFlagWorkDirectory(),
}
}
func getDefaultAction(config *Config) cli.ActionFunc {
return func(c *cli.Context) error {
var err error
config.RunDefault = true
config.BuildOutput = c.String("output")
if config.CommandArguments, err = shellquote.Split(c.String("args")); err != nil {
panic(err)
}
config.CommandsDelimiter = c.String("exec-delim")
config.EnvVars = c.StringSlice("env")
config.ExecGroups = c.StringSlice("exec")
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
}
}