Преглед на файлове

add -detect flag to just display project types.

Lucas Stadler преди 11 години
родител
ревизия
f6f838cb84
променени са 3 файла, в които са добавени 12 реда и са изтрити 23 реда
  1. 0 1
      go/.gitignore
  2. 12 0
      go/qst.go
  3. 0 22
      go/test_detect.go

+ 0 - 1
go/.gitignore

@ -1,7 +1,6 @@
1 1
.go
2 2
3 3
qst
4
test_detect
5 4
6 5
examples/hello
7 6
examples/hello_web

+ 12 - 0
go/qst.go

@ -34,6 +34,7 @@ var autoRestart = flag.Bool("autorestart", true, "automatically restart after co
34 34
var command = flag.String("command", "", "command to run ({file} will be substituted)")
35 35
var projectType = flag.String("type", "", "project type to use (autodetected if not present)")
36 36
var phase = flag.String("phase", "run", "which phase to run (build, run or test)")
37
var justDetect = flag.Bool("detect", false, "detect the project type and exit")
37 38
38 39
func main() {
39 40
	log.SetFlags(log.Ldate | log.Ltime | log.Lshortfile)
@ -58,6 +59,17 @@ func main() {
58 59
59 60
	file := args[0]
60 61
62
	if *justDetect {
63
		projects := detect.DetectAll(file)
64
		if len(projects) == 0 {
65
			log.Fatal("unkown project type")
66
		}
67
		for _, project := range projects {
68
			fmt.Println(project.Id)
69
		}
70
		os.Exit(0)
71
	}
72
61 73
	var cmd string
62 74
	if !flagEmpty(command) {
63 75
		cmd = *command

+ 0 - 22
go/test_detect.go

@ -1,22 +0,0 @@
1
package main
2
3
import (
4
	"fmt"
5
	"os"
6
7
	"./detect"
8
)
9
10
func main() {
11
	if len(os.Args) < 2 {
12
		fmt.Printf("Usage: %s <file>\n", os.Args[0])
13
		os.Exit(1)
14
	}
15
16
	file := os.Args[1]
17
18
	for _, project := range detect.DetectAll(file) {
19
		runCmd := project.Commands["run"]
20
		fmt.Printf("%v (%v)\n", project.Id, runCmd)
21
	}
22
}