-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (48 loc) · 1.2 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
package main
import (
"os"
"github.com/alecthomas/kong"
"github.com/arctir/flightdeck-cli/commands"
)
const defaultAPIEndpoint = "https://api.arctir.cloud/v1"
const defaultLocalAPIEndpoint = "http://localhost:9090/v1"
const defaultAuthEndpoint = "https://auth.arctir.cloud/realms/arctir-prod"
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
configPath, err := commands.ConfigPath()
if err != nil {
panic(err)
}
apiEndpoint := defaultAPIEndpoint
authEndpoint := defaultAuthEndpoint
flightdeckEnv := os.Getenv("FLIGHTDECK_ENV")
if flightdeckEnv == "local" {
apiEndpoint = defaultLocalAPIEndpoint
}
cli := commands.Cli{}
commandContext := commands.Context{}
ctx := kong.Parse(&cli,
kong.Name("flightdeck"),
kong.Vars{
"apiEndpoint": apiEndpoint,
"authEndpoint": authEndpoint,
"configPath": *configPath,
"buildVersion": version,
"buildCommit": commit,
"buildDate": date,
},
kong.Bind(&commandContext),
kong.Bind(&cli.Globals),
kong.UsageOnError(),
kong.ConfigureHelp(kong.HelpOptions{
Compact: true,
Summary: false,
NoExpandSubcommands: true,
}))
err = ctx.Run(&cli.Globals)
ctx.FatalIfErrorf(err)
}