forked from DEVELOPEST/gtm-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
89 lines (82 loc) · 1.88 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
89
// Copyright 2016 Michael Schenk. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package main
import (
"fmt"
"os"
"github.com/DEVELOPEST/gtm-core/command"
"github.com/DEVELOPEST/gtm-core/util"
"github.com/mitchellh/cli"
)
// Version is the released version set during the release build process
var Version = "0.0.0"
func main() {
profileFunc := util.Profile(fmt.Sprintf("%+v", os.Args))
util.Debug.Printf("%+v", os.Args)
ui := &cli.ColoredUi{
ErrorColor: cli.UiColorRed,
WarnColor: cli.UiColorYellow,
InfoColor: cli.UiColorCyan,
Ui: &cli.BasicUi{Writer: os.Stdout, Reader: os.Stdin},
}
c := cli.NewCLI("gtm", Version)
c.Args = os.Args[1:]
c.HelpWriter = os.Stdout
c.ErrorWriter = os.Stderr
c.Commands = map[string]cli.CommandFactory{
"init": func() (cli.Command, error) {
return &command.InitCmd{
UI: ui,
}, nil
},
"record": func() (cli.Command, error) {
return &command.RecordCmd{
UI: ui,
}, nil
},
"commit": func() (cli.Command, error) {
return &command.CommitCmd{
UI: ui,
}, nil
},
"report": func() (cli.Command, error) {
return &command.ReportCmd{
UI: ui,
}, nil
},
"status": func() (cli.Command, error) {
return &command.StatusCmd{
UI: ui,
}, nil
},
"verify": func() (cli.Command, error) {
return &command.VerifyCmd{
UI: ui,
Version: Version,
}, nil
},
"uninit": func() (cli.Command, error) {
return &command.UninitCmd{
UI: ui,
}, nil
},
"clean": func() (cli.Command, error) {
return &command.CleanCmd{
UI: ui,
}, nil
},
"rewrite": func() (cli.Command, error) {
return &command.RewriteCmd{
UI: ui,
}, nil
},
}
exitStatus, err := c.Run()
profileFunc()
if err != nil {
ui.Error(err.Error())
}
util.Debug.Print("exitStatus:", exitStatus)
os.Exit(exitStatus)
}