-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
51 lines (41 loc) · 908 Bytes
/
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
package main
import (
"fmt"
"github.com/chrisroberts/void/command"
"github.com/mitchellh/cli"
"os"
)
const VERSION = "0.1.2"
const APP_NAME = "void"
// Available commands
var Commands map[string]cli.CommandFactory
func main() {
os.Exit(realMain())
}
func realMain() int {
baseUi := &cli.BasicUi{Writer: os.Stdout, ErrorWriter: os.Stderr}
ui := &cli.ColoredUi{
ErrorColor: cli.UiColorRed,
InfoColor: cli.UiColorGreen,
OutputColor: cli.UiColorNone,
WarnColor: cli.UiColorYellow,
Ui: baseUi,
}
exitCode := 1
debug := false
if os.Getenv("VOID_DEBUG") != "" {
debug = true
}
commands := command.Commands(APP_NAME, ui, debug)
c := &cli.CLI{
Args: os.Args[1:],
Commands: commands,
Name: APP_NAME,
Version: VERSION,
}
exitCode, err := c.Run()
if err != nil {
ui.Error(fmt.Sprintf("Unexpected error encountered: %s", err))
}
return exitCode
}