mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Rather than referencing wtc.Config, instead pass the global config Also, look up config for the module early and pass that in sooner, to deal with fewer long paths and get rid of the ConfigKey variable
59 lines
1.7 KiB
Go
59 lines
1.7 KiB
Go
package gcal
|
|
|
|
import (
|
|
"github.com/olebedev/config"
|
|
"github.com/wtfutil/wtf/cfg"
|
|
)
|
|
|
|
const configKey = "gcal"
|
|
|
|
type colors struct {
|
|
day string
|
|
description string
|
|
past string
|
|
title string
|
|
|
|
highlights []interface{}
|
|
}
|
|
|
|
type Settings struct {
|
|
colors
|
|
common *cfg.Common
|
|
|
|
conflictIcon string
|
|
currentIcon string
|
|
displayResponseStatus bool
|
|
email string
|
|
eventCount int
|
|
multiCalendar bool
|
|
secretFile string
|
|
showDeclined bool
|
|
textInterval int
|
|
withLocation bool
|
|
}
|
|
|
|
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
|
|
|
settings := Settings{
|
|
common: cfg.NewCommonSettingsFromModule(name, ymlConfig, globalConfig),
|
|
|
|
conflictIcon: ymlConfig.UString("conflictIcon", "🚨"),
|
|
currentIcon: ymlConfig.UString("currentIcon", "🔸"),
|
|
displayResponseStatus: ymlConfig.UBool("displayResponseStatus", true),
|
|
email: ymlConfig.UString("email", ""),
|
|
eventCount: ymlConfig.UInt("eventCount", 10),
|
|
multiCalendar: ymlConfig.UBool("multiCalendar", false),
|
|
secretFile: ymlConfig.UString("secretFile", ""),
|
|
showDeclined: ymlConfig.UBool("showDeclined", false),
|
|
textInterval: ymlConfig.UInt("textInterval", 30),
|
|
withLocation: ymlConfig.UBool("withLocation", true),
|
|
}
|
|
|
|
settings.colors.day = ymlConfig.UString("colors.day", "forestgreen")
|
|
settings.colors.description = ymlConfig.UString("colors.description", "white")
|
|
settings.colors.past = ymlConfig.UString("colors.past", "gray")
|
|
settings.colors.title = ymlConfig.UString("colors.title", "white")
|
|
|
|
return &settings
|
|
}
|