This repository has been archived by the owner on Dec 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
103 lines (93 loc) · 1.85 KB
/
config.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
package config
const (
crdFile = ".cred.yaml"
optFile = "option.yaml"
colFile = "color.yaml"
)
// Config 設定構造体
type Config struct {
Cred *cred
Option *option
Color *color
}
type cred struct {
Token string
Secret string
}
type option struct {
ConfigDir string
Counts string
DateFormat string
TimeFormat string
}
type color struct {
Accent1 string
Accent2 string
Accent3 string
Error string
BoxForground string
Separator string
UserName string
ScreenName string
Reply string
Hashtag string
Favorite string
Retweet string
Verified string
Protected string
Following string
FollowedBy string
Block string
Mute string
}
// New 構造体を初期化
func New() *Config {
return &Config{
Cred: &cred{
Token: "",
Secret: "",
},
Option: &option{
ConfigDir: getConfigDir(),
Counts: "25",
DateFormat: "2006/01/02",
TimeFormat: "15:04:05",
},
Color: &color{
Accent1: "#e06c75",
Accent2: "#c678dd",
Accent3: "#56b6c2",
Error: "#e06c75",
BoxForground: "#000000",
Separator: "#707070",
UserName: "#faf8f7",
ScreenName: "#9c9c9c",
Reply: "#56b6c2",
Hashtag: "#61afef",
Favorite: "#e887b9",
Retweet: "#98c379",
Verified: "#5685d1",
Protected: "#787878",
Following: "#1877c9",
FollowedBy: "#18a0c9",
Block: "#e06c75",
Mute: "#e5c07b",
},
}
}
// Save 保存
func (cfg *Config) Save() {
cfg.saveYaml(crdFile, cfg.Cred)
cfg.saveYaml(optFile, cfg.Option)
cfg.saveYaml(colFile, cfg.Color)
}
// Load 読込
func (cfg *Config) Load() bool {
if !cfg.configFileExists() {
return false
}
cfg.loadYaml(crdFile, cfg.Cred)
cfg.loadYaml(optFile, cfg.Option)
cfg.loadYaml(colFile, cfg.Color)
return true
}