1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00
wtf/modules/subreddit/settings.go
2019-09-26 22:58:43 +01:00

34 lines
1012 B
Go

package subreddit
import (
"github.com/olebedev/config"
"github.com/wtfutil/wtf/cfg"
)
const (
defaultFocusable = true
)
// Settings contains the settings for the subreddit view
type Settings struct {
common *cfg.Common
subreddit string `help:"Subreddit to look at" optional:"false"`
numberOfPosts int `help:"Number of posts to show. Default is 10." optional:"true"`
sortOrder string `help:"Sort order for the posts (hot, new, rising, top), default hot" optional:"true"`
}
// NewSettingsFromYAML creates the settings for this module from a yaml file
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
subreddit := ymlConfig.UString("subreddit")
settings := Settings{
common: cfg.NewCommonSettingsFromModule(name, subreddit, defaultFocusable, ymlConfig, globalConfig),
numberOfPosts: ymlConfig.UInt("numberOfPosts", 10),
sortOrder: ymlConfig.UString("sortOrder", "hot"),
subreddit: subreddit,
}
return &settings
}