-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgobl.go
76 lines (61 loc) · 1.35 KB
/
gobl.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
package main
import (
"os"
"runtime"
. "github.com/kettek/gobl"
)
func main() {
var exe string
if runtime.GOOS == "windows" {
exe = ".exe"
}
var goblEnv []string
var extraArgs []interface{}
if len(os.Args) > 2 {
split := len(os.Args) - 3
for i, a := range os.Args[2:] {
if a == "--" {
split = i
break
}
}
goblEnv = os.Args[2 : 2+split]
for _, v := range os.Args[2+split+1:] {
extraArgs = append(extraArgs, v)
}
}
// Adjust exe if an env is GOOD=windows
for _, v := range goblEnv {
if v == "GOOS=windows" {
exe = ".exe"
}
}
runArgs := append([]interface{}{}, "./magnet"+exe)
runArgs = append(runArgs, extraArgs...)
Task("build").
Exec("go", "build", "./cmd/magnet")
Task("watch").
Watch("cmd/*/*", "cmd/*/*/*", "pkg/*/*", "pkg/*/*/*", "pkg/*/*/*/*").
Signaler(SigQuit).
Run("build").
Run("run")
Task("watch-only").
Watch("cmd/*/*", "cmd/*/*/*", "pkg/*/*", "pkg/*/*/*", "pkg/*/*/*/*").
Run("build")
Task("host").
Watch("./magnet" + exe).
Signaler(SigQuit).
Run("runServer")
Task("join").
Watch("./magnet" + exe).
Signaler(SigQuit).
Run("runClient")
Task("runServer").
Exec(append(runArgs, "-n", "server", "--host", ":9999")...)
Task("runClient").
Sleep("500ms").
Exec(append(runArgs, "-n", "client", "--join", "localhost:9999")...)
Task("run").
Exec(runArgs...)
Go()
}