-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (36 loc) · 776 Bytes
/
main.go
File metadata and controls
44 lines (36 loc) · 776 Bytes
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
package main
import (
"context"
"os"
"github.com/fatih/color"
"github.com/urfave/cli/v2"
)
const (
debugColor = color.FgCyan
errorColor = color.FgRed
)
var commands = loadCommands()
func setClient(c *cli.Context) error {
debugFn := c.Context.Value("debugFunc").(func(message string))
client, err := initClient(c.String("profile"), debugFn)
if err != nil {
return err
}
//lint:ignore SA1029 initClient before subcommand
c.Context = context.WithValue(c.Context, "client", client)
return nil
}
func msg(err error) int {
if err != nil {
red := color.New(errorColor).FprintfFunc()
red(os.Stderr, "%s: %v\n", os.Args[0], err)
return 1
}
return 0
}
func run(app *cli.App) int {
return msg(app.Run(os.Args))
}
func main() {
os.Exit(run(initApp()))
}