-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (50 loc) · 1.09 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
package main
import (
"log"
"os"
"github.com/rs/zerolog"
"github.com/urfave/cli/v2"
)
func main() {
var configPath string
var debugMode bool
app := &cli.App{
Name: "wip-go",
Description: "Do Not Merge, as a service!",
Commands: []*cli.Command{
{
Name: "run",
Usage: "Runs the application",
Action: func(cCtx *cli.Context) error {
logger := zerolog.New(os.Stdout).With().Timestamp().Logger()
zerolog.DefaultContextLogger = &logger
if debugMode {
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
config, err := ReadConfig(configPath)
if err != nil {
panic(err)
}
runApp(*config, logger)
return nil
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "config-file",
Value: "./config.yaml",
Usage: "The path to the configuration file",
Aliases: []string{"c"},
Destination: &configPath,
},
&cli.BoolFlag{
Name: "debug",
Destination: &debugMode,
},
},
},
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}