github.com/wtfutil/wtf@v0.43.0/modules/football/settings.go (about) 1 package football 2 3 import ( 4 "os" 5 6 "github.com/olebedev/config" 7 "github.com/wtfutil/wtf/cfg" 8 ) 9 10 const ( 11 defaultFocusable = true 12 defaultTitle = "football" 13 ) 14 15 type Settings struct { 16 *cfg.Common 17 18 apiKey string `help:"Your Football-data API token."` 19 league string `help:"Name of the competition. For example PL"` 20 favTeam string `help:"Teams to follow in mentioned league"` 21 matchesFrom int `help:"Matches till Today (Today - Number of days), Default: 2"` 22 matchesTo int `help:"Matches from Today (Today + Number of days), Default: 5"` 23 standingCount int `help:"Top N number of teams in standings, Default: 5"` 24 } 25 26 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 27 28 settings := Settings{ 29 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 30 31 apiKey: ymlConfig.UString("apiKey", ymlConfig.UString("apikey", os.Getenv("WTF_FOOTBALL_API_KEY"))), 32 league: ymlConfig.UString("league", ymlConfig.UString("league", os.Getenv("WTF_FOOTBALL_LEAGUE"))), 33 favTeam: ymlConfig.UString("favTeam", ymlConfig.UString("favTeam", os.Getenv("WTF_FOOTBALL_TEAM"))), 34 matchesFrom: ymlConfig.UInt("matchesFrom", 5), 35 matchesTo: ymlConfig.UInt("matchesTo", 5), 36 standingCount: ymlConfig.UInt("standingCount", 5), 37 } 38 39 cfg.ModuleSecret(name, globalConfig, &settings.apiKey).Load() 40 41 settings.SetDocumentationPath("sports/football") 42 43 return &settings 44 }