-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
56 lines (47 loc) · 1.18 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/urfave/cli"
"github.com/rs/zerolog/log"
"github.com/slickqa/slick/slickconfig"
"github.com/slickqa/slick/commands"
"github.com/slickqa/slick/slickversion"
"github.com/rs/zerolog"
"golang.org/x/crypto/ssh/terminal"
)
func main() {
app := cli.NewApp()
app.Name = "slick"
app.Version = slickversion.GetVersion()
app.Flags = []cli.Flag {
cli.StringFlag{
Name: "config, c",
},
cli.BoolFlag{
Name: "debug, d",
},
}
zerolog.SetGlobalLevel(zerolog.InfoLevel)
if terminal.IsTerminal(int(os.Stdout.Fd())) {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
}
app.Before = func(c *cli.Context) error {
if c.Bool("d") {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
if c.IsSet("c") {
log.Info().Str("source", c.String("c")).Msg("Loading config from source specified")
slickconfig.Configuration.LoadFromLocation(c.String("c"))
} else {
log.Debug().Msg("Loading config from standard locations.")
slickconfig.Configuration.LoadFromStandardLocations()
}
return nil
}
app.Commands = []cli.Command{
commands.InitCommand,
commands.ServeCommand,
commands.GenerateTokenCommand,
}
app.Run(os.Args)
}