-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
54 lines (45 loc) · 1.15 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
package main
import (
"os"
"github.com/Valutac/meraxes/command"
"github.com/mitchellh/cli"
"github.com/spf13/viper"
"go.uber.org/zap"
)
func init() {
viper.SetConfigName("config")
viper.SetConfigType("yaml")
viper.AddConfigPath(".")
viper.SetDefault("server.port", 5000)
viper.SetDefault("scheduler.time", 60)
viper.SetDefault("notification.active", true)
_ = viper.ReadInConfig()
}
var ui cli.Ui
func main() {
zapConfig := zap.NewProductionConfig()
zapConfig.OutputPaths = []string{"stdout"}
zapConfig.ErrorOutputPaths = []string{"stderr"}
logger, _ := zapConfig.Build()
defer logger.Sync()
ui = &cli.BasicUi{Writer: os.Stdout}
commands := &cli.CLI{
Args: os.Args[1:],
Commands: map[string]cli.CommandFactory{
"check": func() (cli.Command, error) {
return command.NewCheckCmd(ui, logger), nil
},
"web": func() (cli.Command, error) {
return command.NewWebCmd(ui, logger), nil
},
},
HelpFunc: cli.BasicHelpFunc("meraxes"),
Version: "1.0.0",
}
exitCode, err := commands.Run()
if err != nil {
logger.Error("error executing meraxes", zap.Strings("args", os.Args), zap.Error(err))
os.Exit(1)
}
os.Exit(exitCode)
}