From c1fc7c7367b1ccced3634272918d3299a0fef4ea Mon Sep 17 00:00:00 2001 From: miladj <16033489+miladj@users.noreply.github.com> Date: Sat, 19 Apr 2025 22:30:06 +0330 Subject: [PATCH 1/2] add ini file config support --- internal/cmd/cmd.go | 3 +++ internal/cmd/options.go | 3 +++ 2 files changed, 6 insertions(+) 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. From e876827ee588ee4f4c9f5e5f06b130bf3aef65db Mon Sep 17 00:00:00 2001 From: miladj <16033489+miladj@users.noreply.github.com> Date: Wed, 30 Apr 2025 21:54:59 +0330 Subject: [PATCH 2/2] update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) 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