mirror of
https://github.com/taigrr/wtf
synced 2025-01-18 04:03:14 -08:00
Have the modules set their own titles If no title is specified, use this title, rather than default to name
64 lines
1.4 KiB
Go
64 lines
1.4 KiB
Go
package bittrex
|
|
|
|
import (
|
|
"github.com/olebedev/config"
|
|
"github.com/wtfutil/wtf/cfg"
|
|
)
|
|
|
|
const defaultTitle = "Bittrex"
|
|
|
|
type colors struct {
|
|
base struct {
|
|
name string
|
|
displayName string
|
|
}
|
|
market struct {
|
|
name string
|
|
field string
|
|
value string
|
|
}
|
|
}
|
|
|
|
type currency struct {
|
|
displayName string
|
|
market []interface{}
|
|
}
|
|
|
|
type summary struct {
|
|
currencies map[string]*currency
|
|
}
|
|
|
|
type Settings struct {
|
|
colors
|
|
common *cfg.Common
|
|
summary
|
|
}
|
|
|
|
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
|
|
|
|
settings := Settings{
|
|
common: cfg.NewCommonSettingsFromModule(name, defaultTitle, ymlConfig, globalConfig),
|
|
}
|
|
|
|
settings.colors.base.name = ymlConfig.UString("colors.base.name")
|
|
settings.colors.base.displayName = ymlConfig.UString("colors.base.displayName")
|
|
|
|
settings.colors.market.name = ymlConfig.UString("colors.market.name")
|
|
settings.colors.market.field = ymlConfig.UString("colors.market.field")
|
|
settings.colors.market.value = ymlConfig.UString("colors.market.value")
|
|
|
|
settings.summary.currencies = make(map[string]*currency)
|
|
for key, val := range ymlConfig.UMap("summary") {
|
|
coercedVal := val.(map[string]interface{})
|
|
|
|
currency := ¤cy{
|
|
displayName: coercedVal["displayName"].(string),
|
|
market: coercedVal["market"].([]interface{}),
|
|
}
|
|
|
|
settings.summary.currencies[key] = currency
|
|
}
|
|
|
|
return &settings
|
|
}
|