github.com/wtfutil/wtf@v0.43.0/modules/devto/settings.go (about)

     1  package devto
     2  
     3  import (
     4  	"github.com/olebedev/config"
     5  
     6  	"github.com/wtfutil/wtf/cfg"
     7  )
     8  
     9  const (
    10  	defaultFocusable = true
    11  	defaultTitle     = "dev.to | News Feed"
    12  )
    13  
    14  // Settings defines the configuration options for this module
    15  type Settings struct {
    16  	*cfg.Common
    17  
    18  	numberOfArticles int    `help:"Number of stories to show. Default is 10" optional:"true"`
    19  	contentTag       string `help:"List articles from a specific tag. Default is empty" optional:"true"`
    20  	contentUsername  string `help:"List articles from a specific user. Default is empty" optional:"true"`
    21  	contentState     string `help:"Order the feed by fresh/rising. Default is rising" optional:"true"`
    22  }
    23  
    24  // NewSettingsFromYAML creates and returns an instance of Settings with configuration options populated
    25  func NewSettingsFromYAML(name string, yamlConfig *config.Config, globalConfig *config.Config) *Settings {
    26  	settings := Settings{
    27  		Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, yamlConfig, globalConfig),
    28  
    29  		numberOfArticles: yamlConfig.UInt("numberOfArticles", 10),
    30  		contentTag:       yamlConfig.UString("contentTag", ""),
    31  		contentUsername:  yamlConfig.UString("contentUsername", ""),
    32  		contentState:     yamlConfig.UString("contentState", ""),
    33  	}
    34  
    35  	return &settings
    36  }