Browse Source

Add explicit config arg

This is useful for when your config file isn't in one of the usual
locations.
tags/v0.4.9
Sam Willcocks 5 months ago
parent
commit
134ee05bd4
1 changed files with 9 additions and 4 deletions
  1. 9
    4
      main.go

+ 9
- 4
main.go View File

@@ -31,14 +31,19 @@ type IRCCat struct {
31 31
 
32 32
 func main() {
33 33
 	debug := flag.Bool("debug", false, "Print raw IRC lines")
34
+	configFile := flag.String("config", "", "Path to config file to use")
34 35
 	flag.Parse()
35 36
 
36 37
 	loggo.ConfigureLoggers("<root>=INFO")
37 38
 	log.Infof("IRCCat %s (%s) starting...", branch, revision)
38
-	viper.SetConfigName("irccat")
39
-	viper.AddConfigPath("/run/secrets")
40
-	viper.AddConfigPath("/etc")
41
-	viper.AddConfigPath(".")
39
+	if *configFile != "" {
40
+		viper.SetConfigFile(*configFile)
41
+	} else {
42
+		viper.SetConfigName("irccat")
43
+		viper.AddConfigPath("/run/secrets")
44
+		viper.AddConfigPath("/etc")
45
+		viper.AddConfigPath(".")
46
+	}
42 47
 	var err error
43 48
 
44 49
 	err = viper.ReadInConfig()

Loading…
Cancel
Save