|
|
@ -32,6 +32,7 @@ qst hello.go - compiles & runs hello.go
|
|
32
|
32
|
var delay = flag.Duration("delay", 1*time.Second, "time to wait until restart")
|
|
33
|
33
|
var autoRestart = flag.Bool("autorestart", true, "automatically restart after command exists")
|
|
34
|
34
|
var command = flag.String("command", "", "command to run ({file} will be substituted)")
|
|
|
35
|
var projectType = flag.String("type", "", "project type to use (autodetected if not present)")
|
|
35
|
36
|
|
|
36
|
37
|
func main() {
|
|
37
|
38
|
log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
|
|
|
@ -56,10 +57,18 @@ func main() {
|
|
56
|
57
|
// }
|
|
57
|
58
|
|
|
58
|
59
|
var cmd string
|
|
59
|
|
if command != nil && strings.TrimSpace(*command) != "" {
|
|
|
60
|
if !flagEmpty(command) {
|
|
60
|
61
|
cmd = *command
|
|
61
|
62
|
} else {
|
|
62
|
63
|
project, err := detect.Detect(file)
|
|
|
64
|
if !flagEmpty(projectType) {
|
|
|
65
|
project = detect.GetById(*projectType)
|
|
|
66
|
if project == nil {
|
|
|
67
|
log.Fatalf("unknown type: `%s'", *projectType)
|
|
|
68
|
} else if !project.Detect(file) {
|
|
|
69
|
log.Fatalf("%s doesn't match type %s!", file, *projectType)
|
|
|
70
|
}
|
|
|
71
|
}
|
|
63
|
72
|
if err != nil {
|
|
64
|
73
|
log.Fatal("error: ", err)
|
|
65
|
74
|
}
|
|
|
@ -87,6 +96,10 @@ func main() {
|
|
87
|
96
|
runner.Stop()
|
|
88
|
97
|
}
|
|
89
|
98
|
|
|
|
99
|
func flagEmpty(stringFlag *string) bool {
|
|
|
100
|
return stringFlag == nil || strings.TrimSpace(*stringFlag) == ""
|
|
|
101
|
}
|
|
|
102
|
|
|
90
|
103
|
func runCmd(file string, runner *Runner) {
|
|
91
|
104
|
runner.Start()
|
|
92
|
105
|
lastMtime := time.Now()
|