Handle config options

This commit is contained in:
nemunaire 2025-10-28 19:23:39 +07:00
commit accd7e75d8
6 changed files with 192 additions and 1 deletions

24
internal/config/cli.go Normal file
View file

@ -0,0 +1,24 @@
package config
import (
"flag"
)
// declareFlags registers flags for the structure Options.
func declareFlags(o *Config) {
flag.StringVar(&o.Bind, "bind", ":8081", "Bind port/socket")
}
// parseCLI parse the flags and treats extra args as configuration filename.
func parseCLI(o *Config) error {
flag.Parse()
for _, conf := range flag.Args() {
err := parseFile(o, conf)
if err != nil {
return err
}
}
return nil
}