Pierre-Olivier Mercier
2c146f5615
All checks were successful
continuous-integration/drone/tag Build is passing
39 lines
740 B
Go
39 lines
740 B
Go
package config
|
|
|
|
import (
|
|
"flag"
|
|
"strings"
|
|
)
|
|
|
|
type Config struct {
|
|
DevProxy string
|
|
Bind string
|
|
ExternalURL URL
|
|
BaseURL string
|
|
|
|
LevelDBPath string
|
|
SettingsFile string
|
|
TracksDir string
|
|
GongsDir string
|
|
ActionsDir string
|
|
RoutinesDir string
|
|
|
|
SampleRate int
|
|
}
|
|
|
|
// 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
|
|
}
|