forked from nathany/looper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlooper.go
59 lines (51 loc) · 985 Bytes
/
looper.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
// Autotesting tool with readline support.
package main
import (
"flag"
"log"
"github.com/nathany/looper/gat"
)
type Runner interface {
RunOnChange(file string)
RunAll()
}
func EventLoop(runner Runner, debug bool) {
commands := CommandParser()
watcher, err := NewRecursiveWatcher("./")
if err != nil {
log.Fatal(err)
}
watcher.Run(debug)
defer watcher.Close()
out:
for {
select {
case file := <-watcher.Files:
runner.RunOnChange(file)
case folder := <-watcher.Folders:
PrintWatching(folder)
case command := <-commands:
switch command {
case Exit:
break out
case RunAll:
runner.RunAll()
case Help:
DisplayHelp()
}
}
}
}
func main() {
var tags string
var debug bool
flag.StringVar(&tags, "tags", "", "a list of build tags for testing.")
flag.BoolVar(&debug, "debug", false, "adds additional logging")
flag.Parse()
runner := &gat.Run{Tags: tags}
Header()
if debug {
DebugEnabled()
}
EventLoop(runner, debug)
}