Parse env vars

This commit is contained in:
Dan Jones 2024-02-10 11:06:00 -06:00
commit 85f666cbc2
5 changed files with 57 additions and 17 deletions

View file

@ -1,16 +1,14 @@
package config
import mapst "github.com/mitchellh/mapstructure"
type Config struct {
Input Input
Outputs Outputs `toml:"output"`
}
type Input struct {
Path string
Recurse bool
Ext string
Path string `env:"LOG_PATH"`
Recurse bool `env:"LOG_RECURSE"`
Ext string `env:"LOG_EXT"`
}
type Outputs map[string]Output
@ -20,16 +18,6 @@ type Output struct {
Config map[string]any
}
func (oo Outputs) Stdout() (s Stdout, enabled bool) {
o, ok := oo["stdout"]
if !ok {
return s, false
}
enabled = o.Enabled
mapst.Decode(o.Config, &s)
return
}
type Stdout struct {
Json bool
Json bool `env:"LOG_STDOUT_JSON"`
}