This repository has been archived by the owner on May 8, 2023. It is now read-only.
/
main.go
88 lines (68 loc) · 2.17 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package main
import (
"os"
"path/filepath"
"runtime"
"strings"
"github.com/pieterclaerhout/go-james/cmd/dockerimage"
"github.com/pieterclaerhout/go-james/cmd/staticcheck"
"github.com/pieterclaerhout/go-james/cmd/builder"
"github.com/pieterclaerhout/go-james/cmd/cleaner"
"github.com/pieterclaerhout/go-james/cmd/creator"
"github.com/pieterclaerhout/go-james/cmd/debugger"
"github.com/pieterclaerhout/go-james/cmd/installer"
"github.com/pieterclaerhout/go-james/cmd/packager"
"github.com/pieterclaerhout/go-james/cmd/runner"
"github.com/pieterclaerhout/go-james/cmd/tester"
"github.com/pieterclaerhout/go-james/cmd/uninstaller"
"github.com/pieterclaerhout/go-james/cmd/version"
"github.com/pieterclaerhout/go-james/internal"
"github.com/pieterclaerhout/go-james/internal/common"
rawrunner "github.com/pieterclaerhout/go-james/internal/runner"
"github.com/pieterclaerhout/go-james/versioninfo"
"github.com/pieterclaerhout/go-log"
"github.com/tucnak/climax"
)
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
log.PrintColors = true
log.DebugMode = common.Golang{}.IsDebug()
var commandName string
var result int
if len(os.Args) > 1 {
commandName = strings.TrimSpace(strings.ToLower(os.Args[1]))
}
if commandName == "run" {
args := []string{}
if len(os.Args) > 2 {
args = os.Args[2:]
}
tool := rawrunner.Runner{
Args: args,
}
executor := internal.NewExecutor("")
result = executor.RunTool(tool, true)
} else {
exePath, _ := os.Executable()
exeName := filepath.Base(exePath)
app := climax.New(exeName)
app.Name = versioninfo.ProjectName
app.Brief = versioninfo.ProjectDescription
app.Version = versioninfo.Revision
app.AddCommand(builder.BuildCmd)
app.AddCommand(cleaner.CleanCmd)
app.AddCommand(creator.InitCmd)
app.AddCommand(creator.NewCmd)
app.AddCommand(debugger.DebugCmd)
app.AddCommand(dockerimage.DockerImageCmd)
app.AddCommand(installer.InstallCmd)
app.AddCommand(packager.PackageCmd)
app.AddCommand(runner.RunCmd)
app.AddCommand(staticcheck.StaticcheckCmd)
app.AddCommand(tester.TestCmd)
app.AddCommand(uninstaller.UninstallCmd)
app.AddCommand(version.VersionCmd)
result = app.Run()
}
os.Exit(result)
}