github.com/wtfutil/wtf@v0.43.0/modules/gitter/settings.go (about) 1 package gitter 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 = "Gitter" 13 ) 14 15 type Settings struct { 16 *cfg.Common 17 18 apiToken string `help:"Your Gitter Personal Access Token."` 19 numberOfMessages int `help:"Maximum number of (newest) messages to be displayed. Default is 10" optional:"true"` 20 roomURI string `help:"The room you want to display." values:"Example: wtfutil/Lobby"` 21 } 22 23 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 24 25 settings := Settings{ 26 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 27 28 apiToken: ymlConfig.UString("apiToken", os.Getenv("WTF_GITTER_API_TOKEN")), 29 numberOfMessages: ymlConfig.UInt("numberOfMessages", 10), 30 roomURI: ymlConfig.UString("roomUri", "wtfutil/Lobby"), 31 } 32 33 cfg.ModuleSecret(name, globalConfig, &settings.apiToken).Load() 34 35 return &settings 36 }