-
Notifications
You must be signed in to change notification settings - Fork 21
/
main.go
84 lines (74 loc) · 1.58 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
package main
import (
"os"
"time"
"github.com/bruin-data/bruin/cmd"
"github.com/bruin-data/bruin/pkg/telemetry"
v "github.com/bruin-data/bruin/pkg/version"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
)
var (
version = "dev"
commit = ""
TelemetryKey string
)
func main() {
isDebug := false
color.NoColor = false
var optOut bool
if os.Getenv("TELEMETRY_OPTOUT") != "" {
optOut = true
}
v.Version = version
v.Commit = commit
if TelemetryKey == "" {
TelemetryKey = os.Getenv("TELEMETRY_KEY")
}
telemetry.TelemetryKey = TelemetryKey
telemetry.OptOut = optOut
telemetry.AppVersion = v.Version
client := telemetry.Init()
defer client.Close()
versionCommand := cmd.VersionCmd(v.Commit)
cli.VersionPrinter = func(cCtx *cli.Context) {
err := versionCommand.Action(cCtx)
if err != nil {
panic(err)
}
}
app := &cli.App{
Name: "bruin",
Version: version,
Usage: "The CLI used for managing Bruin-powered data pipelines",
Compiled: time.Now(),
ExitErrHandler: telemetry.ErrorCommand,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "debug",
Value: false,
Usage: "show debug information",
Destination: &isDebug,
},
},
Commands: []*cli.Command{
cmd.Lint(&isDebug),
cmd.Run(&isDebug),
cmd.Render(),
cmd.Lineage(),
cmd.CleanCmd(),
cmd.Format(&isDebug),
cmd.Docs(),
cmd.Init(),
cmd.Internal(),
cmd.Environments(&isDebug),
cmd.Connections(),
cmd.Query(),
versionCommand,
},
}
err := app.Run(os.Args)
if err != nil {
cli.HandleExitCoder(err)
}
}