metrics: actually read flag value

This commit is contained in:
lightclient 2024-11-25 07:51:23 -07:00
parent 1635da8021
commit 4abf2e5afd
No known key found for this signature in database
GPG Key ID: 75C916AFEE20183E
1 changed files with 7 additions and 2 deletions

View File

@ -56,11 +56,16 @@ func init() {
// Now visit the flags we defined which are present in the args and see if we // Now visit the flags we defined which are present in the args and see if we
// should enable metrics. // should enable metrics.
fs.Visit(func(f *flag.Flag) { fs.Visit(func(f *flag.Flag) {
g, ok := f.Value.(flag.Getter)
if !ok {
// Don't expect this to fail, but skip over just in case it does.
return
}
switch f.Name { switch f.Name {
case "metrics": case "metrics":
Enabled = true Enabled = g.Get().(bool)
case "config": case "config":
data, err := os.ReadFile(f.Value.String()) data, err := os.ReadFile(g.Get().(string))
if err != nil { if err != nil {
return return
} }