Skip to content

Commit

Permalink
Parse flags before loading configfile. Fixes #297
Browse files Browse the repository at this point in the history
  • Loading branch information
42wim committed Aug 11, 2020
1 parent fa71682 commit 6715b16
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ func main() {
flag.String("tlsbind", "", "interface:port to bind to. (e.g 127.0.0.1:6697)")
flag.String("tlsdir", ".", "directory to look for key.pem and cert.pem.")

pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()

// Attempt to load values from the config file
if _, err := os.Stat(*flagConfig); err == nil {
v, err = config.LoadConfig(*flagConfig)
Expand All @@ -57,8 +60,6 @@ func main() {
v = viper.New()
}

pflag.CommandLine.AddGoFlagSet(flag.CommandLine)
pflag.Parse()
v.BindPFlags(pflag.CommandLine)

if v.GetBool("debug") {
Expand Down

0 comments on commit 6715b16

Please sign in to comment.