forked from wtfutil/wtf
/
settings.go
79 lines (62 loc) · 1.99 KB
/
settings.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package cryptolive
import (
"github.com/olebedev/config"
"github.com/doctorfree/wtf/cfg"
"github.com/doctorfree/wtf/modules/cryptocurrency/cryptolive/price"
"github.com/doctorfree/wtf/modules/cryptocurrency/cryptolive/toplist"
)
const (
defaultFocusable = false
defaultTitle = "CryptolLive"
)
type colors struct {
from struct {
name string
displayName string
}
to struct {
name string
price string
}
top struct {
from struct {
name string
displayName string
}
to struct {
name string
field string
value string
}
}
}
type Settings struct {
*cfg.Common
colors
currencies map[string]interface{}
top map[string]interface{}
priceSettings *price.Settings
toplistSettings *toplist.Settings
}
func NewSettingsFromYAML(name string, ymlConfig *config.Config, globalConfig *config.Config) *Settings {
currencies, _ := ymlConfig.Map("currencies")
top, _ := ymlConfig.Map("top")
settings := Settings{
Common: cfg.NewCommonSettingsFromModule(name, defaultTitle, defaultFocusable, ymlConfig, globalConfig),
currencies: currencies,
top: top,
priceSettings: price.NewSettingsFromYAML(name, ymlConfig, globalConfig),
toplistSettings: toplist.NewSettingsFromYAML(name, ymlConfig, globalConfig),
}
settings.colors.from.name = ymlConfig.UString("colors.from.name")
settings.colors.from.displayName = ymlConfig.UString("colors.from.displayName")
settings.colors.to.name = ymlConfig.UString("colors.to.name")
settings.colors.to.price = ymlConfig.UString("colors.to.price")
settings.colors.top.from.name = ymlConfig.UString("colors.top.from.name")
settings.colors.top.from.displayName = ymlConfig.UString("colors.top.from.displayName")
settings.colors.top.to.name = ymlConfig.UString("colors.top.to.name")
settings.colors.top.to.field = ymlConfig.UString("colors.top.to.field")
settings.colors.top.to.value = ymlConfig.UString("colors.top.to.value")
settings.SetDocumentationPath("cryptocurrencies/cryptolive")
return &settings
}