-
Notifications
You must be signed in to change notification settings - Fork 0
/
dev.go
53 lines (45 loc) · 927 Bytes
/
dev.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
package main
import (
"flag"
"os"
"strconv"
)
var dev commandHandler
func init() {
dev = func(command string, params []string) {
withoutrun := false
port := 0
flag.BoolVar(&withoutrun, "withoutrun", false, "on genefile without run")
flag.IntVar(&port, "port", 0, "app start port")
flag.CommandLine.Parse(os.Args[2:])
// 1, clear genfiles
done := catalystStartAndDone("clear genfiles")
cmdexer(`
rm boot.go
touch boot.go
rm ./imports/*
`)
done()
// 2, genfile
done = catalystStartAndDone("generate boot.go and importfiles")
cmdexer(`
go generate ./apps/...
`)
done()
if !withoutrun {
// 3, start dev
done = catalystStartAndDone("start dev app")
if port == 0 {
cmdwithstdout(`
DEBUG=true go run *.go
`)
} else {
cmdwithstdout(`
DEBUG=true go run *.go --port=` + strconv.Itoa(port) + `
`)
}
done()
}
}
handlers["dev"] = dev
}