-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
72 lines (66 loc) · 1.78 KB
/
main.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
package main
import (
"flag"
"fmt"
"os"
)
func usage() {
fmt.Printf(`Usage of %s:
Tasks:
gom build [options] : Build with vendor packages
gom install [options] : Install bundled packages into vendor directory
gom test [options] : Run tests with bundles
gom run [options] : Run go file with bundles
gom doc [options] : Run godoc for bundles
gom exec [arguments] : Execute command with bundle environment
gom gen travis-yml : Generate .travis.yml which uses "gom test"
gom gen gomfile : Scan packages from current directory as root
recursively, and generate Gomfile
`, os.Args[0])
os.Exit(1)
}
var productionEnv = flag.Bool("production", false, "production environment")
var developmentEnv = flag.Bool("development", false, "development environment")
var testEnv = flag.Bool("test", false, "test environment")
func main() {
flag.Usage = usage
flag.Parse()
if flag.NArg() == 0 {
usage()
}
handleSignal()
if !*productionEnv && !*developmentEnv && !*testEnv {
*developmentEnv = true
}
var err error
subArgs := flag.Args()[1:]
switch flag.Arg(0) {
case "install", "i":
err = install(subArgs)
case "build", "b":
err = run(append([]string{"go", "build"}, subArgs...), None)
case "test", "t":
err = run(append([]string{"go", "test"}, subArgs...), None)
case "run", "r":
err = run(append([]string{"go", "run"}, subArgs...), None)
case "doc", "d":
err = run(append([]string{"godoc"}, subArgs...), None)
case "exec", "e":
err = run(subArgs, None)
case "gen", "g":
switch flag.Arg(1) {
case "travis-yml":
err = genTravisYml()
case "gomfile":
err = genGomfile()
default:
usage()
}
default:
usage()
}
if err != nil {
fmt.Fprintln(os.Stderr, "gom: ", err)
os.Exit(1)
}
}