github.com/wtfutil/wtf@v0.43.0/modules/digitalclock/settings.go (about) 1 package digitalclock 2 3 import ( 4 "github.com/olebedev/config" 5 "github.com/wtfutil/wtf/cfg" 6 ) 7 8 const ( 9 defaultFocusable = false 10 defaultTitle = "Clocks" 11 ) 12 13 // Settings defines the configuration properties for this module 14 type Settings struct { 15 *cfg.Common 16 17 color string `help:"The color of the clock."` 18 font string `help:"The font of the clock." values:"bigfont or digitalfont"` 19 hourFormat string `help:"The format of the clock." values:"12 or 24"` 20 dateFormat string `help:"The format of the date."` 21 withDate bool `help:"Whether or not to display date information"` 22 withDatePrefix bool `help:"Whether or not to display Date: prefix"` 23 } 24 25 // NewSettingsFromYAML creates a new settings instance from a YAML config block 26 func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings { 27 settings := Settings{ 28 Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig), 29 30 color: ymlConfig.UString("color"), 31 font: ymlConfig.UString("font"), 32 hourFormat: ymlConfig.UString("hourFormat", "24"), 33 dateFormat: ymlConfig.UString("dateFormat", "Monday January 02 2006"), 34 withDate: ymlConfig.UBool("withDate", true), 35 withDatePrefix: ymlConfig.UBool("withDatePrefix", true), 36 } 37 38 return &settings 39 }