github.com/wtfutil/wtf@v0.43.0/modules/hackernews/settings.go (about) 1 package hackernews 2 3 import ( 4 "github.com/olebedev/config" 5 "github.com/wtfutil/wtf/cfg" 6 ) 7 8 const ( 9 defaultFocusable = true 10 defaultTitle = "HackerNews" 11 ) 12 13 type Settings struct { 14 *cfg.Common 15 16 numberOfStories int `help:"Defines number of stories to be displayed. Default is 10" optional:"true"` 17 storyType string `help:"Category of story to see" values:"new, top, job, ask" optional:"true"` 18 } 19 20 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 21 22 settings := Settings{ 23 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 24 25 numberOfStories: ymlConfig.UInt("numberOfStories", 10), 26 storyType: ymlConfig.UString("storyType", "top"), 27 } 28 29 return &settings 30 }