mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
40 lines
774 B
Go
40 lines
774 B
Go
package weather
|
|
|
|
import (
|
|
"os"
|
|
|
|
"github.com/olebedev/config"
|
|
"github.com/wtfutil/wtf/cfg"
|
|
)
|
|
|
|
type colors struct {
|
|
current string
|
|
}
|
|
|
|
type Settings struct {
|
|
colors
|
|
common *cfg.Common
|
|
|
|
apiKey string
|
|
cityIDs []interface{}
|
|
language string
|
|
tempUnit string
|
|
}
|
|
|
|
func NewSettingsFromYAML(ymlConfig *config.Config) *Settings {
|
|
localConfig, _ := ymlConfig.Get("wtf.mods.weather")
|
|
|
|
settings := Settings{
|
|
common: cfg.NewCommonSettingsFromYAML(ymlConfig),
|
|
|
|
apiKey: localConfig.UString("apiKey", os.Getenv("WTF_OWM_API_KEY")),
|
|
cityIDs: localConfig.UList("cityids"),
|
|
language: localConfig.UString("language", "EN"),
|
|
tempUnit: localConfig.UString("tempUnit", "C"),
|
|
}
|
|
|
|
settings.colors.current = localConfig.UString("colors.current", "green")
|
|
|
|
return &settings
|
|
}
|