-
Notifications
You must be signed in to change notification settings - Fork 45
/
main.go
49 lines (40 loc) · 1.21 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
// Copyright 2014 The dogo Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"github.com/zhgo/config"
"github.com/zhgo/console"
"runtime"
"strings"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
var c string
flag.StringVar(&c, "c", console.WorkingDir+"/dogo.json", "Usage: dogo -c=/path/to/dogo.json")
flag.Parse()
var dogo Dogo
gopath := console.Getenv("GOPATH")
c = strings.Replace(c, "{GOPATH}", gopath, -1)
r := map[string]string{"{GOPATH}": gopath}
err := config.NewConfig(c).Replace(r).Parse(&dogo)
if err != nil {
fmt.Printf("[dogo] Warning: no configuration file loaded.\n")
} else {
fmt.Printf("[dogo] Loaded configuration file:\n")
fmt.Printf(" %s\n", c)
}
dogo.NewMonitor()
l := len(dogo.Files)
if l > 0 {
fmt.Printf("[dogo] Ready. %d files to be monitored.\n\n", l)
dogo.BuildAndRun()
dogo.Monitor()
} else {
fmt.Printf("[dogo] Error: Did not find any files. Press any key to exit.\n\n")
var a string
fmt.Scanf("%s", &a)
}
}