reveil/config/config.go

39 lines
740 B
Go
Raw Permalink Normal View History

2022-10-01 17:37:12 +00:00
package config
import (
"flag"
"strings"
)
type Config struct {
2022-10-14 18:08:03 +00:00
DevProxy string
Bind string
ExternalURL URL
BaseURL string
2022-10-05 18:26:37 +00:00
LevelDBPath string
2022-10-05 18:16:53 +00:00
SettingsFile string
TracksDir string
GongsDir string
ActionsDir string
RoutinesDir string
2022-10-14 18:08:03 +00:00
SampleRate int
2022-10-01 17:37:12 +00:00
}
// parseLine treats a config line and place the read value in the variable
// declared to the corresponding flag.
func (c *Config) parseLine(line string) (err error) {
fields := strings.SplitN(line, "=", 2)
orig_key := strings.TrimSpace(fields[0])
value := strings.TrimSpace(fields[1])
key := strings.TrimPrefix(orig_key, "REVEIL_")
key = strings.Replace(key, "_", "-", -1)
key = strings.ToLower(key)
err = flag.Set(key, value)
return
}