forked from acoshift/goreload
-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli.go
100 lines (96 loc) · 2.08 KB
/
cli.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
package main
import "github.com/urfave/cli/v2"
var (
sha1ver string
buildTime string
)
func cliApp() *cli.App {
app := cli.NewApp()
app.Name = "goreload"
app.Usage = "A live reload utility for Go web applications"
app.Action = mainAction
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "bin",
Aliases: []string{"b"},
Value: "./bin/gorl",
Usage: "path to generated binary file",
},
&cli.StringFlag{
Name: "ext",
Aliases: []string{"e"},
Value: `.go|.html`,
Usage: "File extention to watch changes",
},
&cli.StringFlag{
Name: "path",
Aliases: []string{"p"},
Value: ".",
Usage: "Path to watch files from",
},
&cli.StringSliceFlag{
Name: "excludeDir",
Aliases: []string{"x"},
Value: cli.NewStringSlice("bin", ".git", "node_modules"),
Usage: "Relative directories to exclude",
},
&cli.StringFlag{
Name: "buildArgs",
Usage: "Additional go build arguments",
},
&cli.StringFlag{
Name: "runArgs",
Usage: "Additional arguments when run app",
},
&cli.StringFlag{
Name: "logPrefix",
Usage: "Log prefix",
Value: "",
},
&cli.DurationFlag{
Name: "delay",
Usage: "Delay build after detect changes",
Value: 200,
},
&cli.BoolFlag{
Name: "showWatchedFiles",
Aliases: []string{"swf"},
Usage: "Verbose output",
Value: false,
},
&cli.BoolFlag{
Name: "debug",
Aliases: []string{"dlv"},
Usage: "Start with debugger attached, require dlv installed",
Value: false,
},
&cli.StringFlag{
Name: "dlvAddr",
Aliases: []string{"da"},
Usage: "dlv debug port",
Value: ":2345",
},
&cli.StringFlag{
Name: "watcher",
Aliases: []string{"w"},
Usage: "Choose default watcher, valid value is bwatch and fsnotify, default is fsnotify",
Value: "fsnotify",
},
}
app.Commands = []*cli.Command{
{
Name: "run",
Usage: "Run the goreload",
Action: mainAction,
},
{
Name: "version",
Usage: "Version info",
Action: verAction,
},
}
return app
}
func verAction(c *cli.Context) error {
return nil
}