From 97397a7924887acfc3ec3697a8ab7c5f3e553189 Mon Sep 17 00:00:00 2001 From: Sam Willcocks Date: Fri, 8 Dec 2023 17:53:01 +0000 Subject: [PATCH] Add explicit config arg This is useful for when your config file isn't in one of the usual locations. --- main.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index c77e355..ab30194 100644 --- a/main.go +++ b/main.go @@ -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("=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()