diff --git a/README.md b/README.md index b794837..07ad174 100644 --- a/README.md +++ b/README.md @@ -173,6 +173,7 @@ Application Options: delayed for a hard-coded period of 3 minutes. Can be specified multiple times. --verbose Verbose output (optional) --output= Path to the log file. If not set, write to stdout. + --config= Path to the config file. Help Options: -h, --help Show this help message diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 56aeea8..ef99ff1 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -26,6 +26,9 @@ func Main() { options := &Options{} parser := goFlags.NewParser(options, goFlags.Default) _, err := parser.Parse() + if err == nil && options.ConfigFile != "" { + err = goFlags.IniParse(options.ConfigFile, options) + } if err != nil { if flagsErr, ok := err.(*goFlags.Error); ok && flagsErr.Type == goFlags.ErrHelp { os.Exit(0) diff --git a/internal/cmd/options.go b/internal/cmd/options.go index 593343f..d0fe2f5 100644 --- a/internal/cmd/options.go +++ b/internal/cmd/options.go @@ -85,6 +85,9 @@ type Options struct { // LogOutput is the optional path to the log file. LogOutput string `long:"output" description:"Path to the log file. If not set, write to stdout."` + + // ConfigFile is the optional path to the config file. + ConfigFile string `long:"config" description:"Path to the config file."` } // String implements fmt.Stringer interface for Options.