-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
52 lines (44 loc) · 1.03 KB
/
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
package main
import (
"flag"
"os"
"os/signal"
"github.com/crispgm/go-van/caravan"
)
var (
confName string
specName string
initYAML bool
inspect bool
deployOnce bool
isVersion bool
)
func main() {
flag.BoolVar(&initYAML, "init", false, "Generate caravan.yml in current path.")
flag.BoolVar(&inspect, "inspect", false, "Inspect config.")
flag.StringVar(&confName, "conf", caravan.DefaultConfName, "Config file name. Default: `caravan.yml`.")
flag.StringVar(&specName, "spec", caravan.DefaultSpec, "Spec name. Default: `master`.")
flag.BoolVar(&deployOnce, "once", false, "Deploy once. Default: false")
flag.BoolVar(&isVersion, "version", false, "Show version info")
flag.Parse()
if isVersion {
version()
return
}
var err error
if initYAML {
err = initConf()
} else {
go func() {
sig := make(chan os.Signal, 10)
signal.Notify(sig, os.Interrupt)
<-sig
caravan.PrintNotice("\nInterrupted by <CTRL+C>")
os.Exit(0)
}()
err = parseConfAndWatch(inspect)
}
if err != nil {
os.Exit(1)
}
}