1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/covid/settings.go
David Bouchare 2f2df04478
[modules] Add new covid tracker module (#1037)
* Add draft of covid module

* Work on pointers

* Add country stats

* Remove recovered, stays at 0

* Handle response code

* One struct for both

* List of countries

* Add test

* Add test for countries

* Fix typos

* Format numbers based on language/locale
2020-12-29 13:33:14 -08:00

32 lines
754 B
Go

package covid
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
const (
defaultFocusable = false
defaultTitle = "Covid tracker"
)
// Settings is the struct for this module's settings
type Settings struct {
*cfg.Common
countries []interface{} `help:"Countries (codes) from which to retrieve stats."`
}
// NewSettingsFromYAML returns the settings from the config yaml file
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
settings := Settings{
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
// List of countries to retrieve stats from
countries: ymlConfig.UList("countries"),
}
return &settings
}