Skip to content

Commit

Permalink
Add explicit config arg
Browse files Browse the repository at this point in the history
This is useful for when your config file isn't in one of the usual
locations.
  • Loading branch information
wlcx committed Dec 8, 2023
1 parent a2a91e5 commit 97397a7
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@ type IRCCat struct {

func main() {
debug := flag.Bool("debug", false, "Print raw IRC lines")
configFile := flag.String("config", "", "Path to config file to use")
flag.Parse()

loggo.ConfigureLoggers("<root>=INFO")
log.Infof("IRCCat %s (%s) starting...", branch, revision)
viper.SetConfigName("irccat")
viper.AddConfigPath("/run/secrets")
viper.AddConfigPath("/etc")
viper.AddConfigPath(".")
if *configFile != "" {
viper.SetConfigFile(*configFile)
} else {
viper.SetConfigName("irccat")
viper.AddConfigPath("/run/secrets")
viper.AddConfigPath("/etc")
viper.AddConfigPath(".")
}
var err error

err = viper.ReadInConfig()
Expand Down

0 comments on commit 97397a7

Please sign in to comment.