-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
47 lines (36 loc) · 991 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
47
package main
import (
"fmt"
"os"
"path"
"github.com/andersnormal/autobot-plugin-slack/cmd"
"github.com/andersnormal/autobot/pkg/plugins/runtime"
"github.com/pkg/errors"
ll "github.com/sirupsen/logrus"
"github.com/spf13/pflag"
"github.com/spf13/viper"
)
func init() {
runtime.OnInitialize(initConfig)
}
func initConfig() {
// set some default flags
pflag.String("name", path.Base(os.Args[0]), "plugin name")
pflag.String("log_format", runtime.DefaultLogFormat, "log format")
pflag.String("log_level", runtime.DefaultLogLevel, "log level")
pflag.BoolP("verbose", "v", false, "verbose")
pflag.BoolP("debug", "d", false, "debug")
pflag.Parse()
viper.BindPFlags(pflag.CommandLine)
viper.BindEnv("cluster_url")
// unmarshal to config
if err := viper.Unmarshal(runtime.Env()); err != nil {
ll.Fatalf(errors.Wrap(err, "cannot unmarshal runtime").Error())
}
fmt.Println(runtime.Env())
}
func main() {
if err := cmd.Slack.Execute(); err != nil {
panic(err)
}
}