-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
46 lines (37 loc) · 882 Bytes
/
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
package main
import (
"pg_permissions/cmd"
"pg_permissions/errors"
"pg_permissions/log"
"github.com/alecthomas/kong"
"github.com/spf13/viper"
)
var (
v *viper.Viper
)
var cli struct {
ConfigPath string `name:"config" short:"c" default:"." help:"Directory to search for config.yaml file" type:"path"`
Postgres cmd.PostgresClientCmd `cmd:"" postgres:"gather permission details"`
}
func initConfig(path string) *viper.Viper {
v = viper.New()
v.SetConfigName("config")
v.AddConfigPath(path)
v.AutomaticEnv()
v.SetConfigType("yaml")
if err := v.ReadInConfig(); err != nil {
log.Fatalln(errors.ErrConfigFileRead)
}
return v
}
func main() {
log.Infoln("Starting main routine")
ctx := kong.Parse(&cli, kong.UsageOnError())
v = initConfig(cli.ConfigPath)
ctx.Bind(v)
err := ctx.Run()
if err != nil {
log.Infoln(err)
log.Fatalf(errors.ErrContextRun)
}
}