forked from pinpox/base16-universal-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
62 lines (55 loc) · 1.83 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
package main
import (
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
)
type SetterConfig struct {
GithubToken string `yaml:"GithubToken"`
SchemesMasterURL string `yaml:"SchemesMasterURL"`
TemplatesMasterURL string `yaml:"TemplatesMasterURL"`
SchemesListFile string `yaml:"SchemesListFile"`
TemplatesListFile string `yaml:"TemplatesListFile"`
SchemesCachePath string `yaml:"SchemesCachePath"`
TemplatesCachePath string `yaml:"TemplatesCachePath"`
DryRun bool `yaml:"DryRun"`
Colorscheme string `yaml:"Colorscheme"`
Applications map[string]StetterAppConfig `yaml:"applications"`
}
type StetterAppConfig struct {
Enabled bool `yaml:"enabled"`
Hook string `yaml:"hook"`
Mode string `yaml:"mode"`
Files map[string]string `yaml:"files"`
}
func NewConfig(path string) SetterConfig {
var conf SetterConfig
file, err := ioutil.ReadFile(path)
if err != nil {
fmt.Fprintf(os.Stderr, "error: %v\n", err)
os.Exit(1)
}
check(err)
err = yaml.Unmarshal((file), &conf)
check(err)
return conf
}
func (c SetterConfig) Show() {
fmt.Println("GithubToken: ", c.GithubToken)
fmt.Println("SchemesListFile: ", c.SchemesListFile)
fmt.Println("TemplatesListFile: ", c.TemplatesListFile)
fmt.Println("SchemesCachePath: ", c.SchemesCachePath)
fmt.Println("TemplatesCachePath: ", c.TemplatesCachePath)
fmt.Println("DryRun: ", c.DryRun)
for k, v := range c.Applications {
fmt.Println(" App: ", k)
fmt.Println(" Enabled: ", v.Enabled)
fmt.Println(" Hook: ", v.Hook)
for k1, v1 := range v.Files {
fmt.Println(" ", k1, " ", v1)
}
}
}
type Application1 struct {
}