Move flags to init()
This commit is contained in:
parent
7ff6e74148
commit
a151b08142
13
bot/bot.go
13
bot/bot.go
@ -1,7 +1,6 @@
|
|||||||
package bot
|
package bot
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -25,6 +24,13 @@ type (
|
|||||||
MessageHandler func(s *discordgo.Session, m *discordgo.MessageCreate)
|
MessageHandler func(s *discordgo.Session, m *discordgo.MessageCreate)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
pflag.Bool("debug", false, "enable debug mode")
|
||||||
|
pflag.Parse()
|
||||||
|
|
||||||
|
viper.BindPFlags(pflag.CommandLine)
|
||||||
|
}
|
||||||
|
|
||||||
func NewBot(s *discordgo.Session, config Config) *Bot {
|
func NewBot(s *discordgo.Session, config Config) *Bot {
|
||||||
return &Bot{Session: s, Config: config}
|
return &Bot{Session: s, Config: config}
|
||||||
}
|
}
|
||||||
@ -114,11 +120,6 @@ func setupConfig() {
|
|||||||
|
|
||||||
C = NewConfig()
|
C = NewConfig()
|
||||||
|
|
||||||
flag.Bool("debug", false, "enable debug logging")
|
|
||||||
pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
|
|
||||||
pflag.Parse()
|
|
||||||
viper.BindPFlags(pflag.CommandLine)
|
|
||||||
|
|
||||||
viper.SetEnvPrefix("BEEPBOOP")
|
viper.SetEnvPrefix("BEEPBOOP")
|
||||||
viper.AutomaticEnv()
|
viper.AutomaticEnv()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user