summaryrefslogtreecommitdiff
path: root/rules/toml.go
diff options
context:
space:
mode:
authorJoop Kiefte <ikojba@gmail.com>2019-01-12 18:09:14 +0100
committerJoop Kiefte <ikojba@gmail.com>2019-01-12 18:09:14 +0100
commitf22108809004ea08f962cc0ad19ef1fa8051bd0c (patch)
treedd398360f93f8b3335d0ad1abec41f2148a4ff00 /rules/toml.go
parentd7978b513fabcbad8d28451373fe4a25e0ef30c9 (diff)
Beginning implementation TOML settings
Diffstat (limited to 'rules/toml.go')
-rw-r--r--rules/toml.go51
1 files changed, 51 insertions, 0 deletions
diff --git a/rules/toml.go b/rules/toml.go
new file mode 100644
index 0000000..4bb5946
--- /dev/null
+++ b/rules/toml.go
@@ -0,0 +1,51 @@
+package rules
+
+import (
+ "github.com/BurntSushi/toml"
+ "os"
+)
+
+type TOMLConf struct{
+ Elements map[string]Set
+ Scenes map[string][]string
+ metadata toml.MetaData
+}
+
+func ReadFile(file string) (TOMLConf, error) {
+ var r TOMLConf
+ m, err := toml.DecodeFile(file, &r)
+ r.metadata = m
+ return r, err
+}
+
+func MustReadFile(file string) TOMLConf {
+ c, err := ReadFile(file)
+ if err != nil {
+ panic(err)
+ }
+ return c
+}
+
+func DefaultConf() TOMLConf {
+ return TOMLConf{
+ Elements: map[string]Set{
+ "default": Default,
+ },
+ Scenes: map[string][]string{
+ "en": []string{"INT", "EXT", "EST", "INT./EXT", "INT/EXT", "EXT/INT", "EXT./INT", "I/E"},
+ "nl": []string{"BIN", "BUI", "BI", "BU", "OPEN", "BIN./BUI", "BUI./BIN", "BIN/BUI", "BI/BU"},
+ "de": []string{"INT", "EXT", "ETABL", "INT./EXT", "INT/EXT", "EXT/INT", "EXT./INT", "I/E"},
+ "fr": []string{"INT", "EXT", "INT./EXT", "INT/EXT", "EXT/INT", "EXT./INT", "I/E"},
+ "eo": []string{"EN", "ENE", "EKST", "EK", "EN/EKST", "EKST/EN", "EKST./EN", "EN./EKST"},
+ "ru": []string{"ИНТ", "НАТ", "ИНТ/НАТ", "ИНТ./НАТ", "НАТ/ИНТ", "НАТ./ИНТ", "ЭКСТ", "И/Н", "Н/И"},
+ },
+ }
+}
+
+func Dump(file string) error {
+ f, err := os.Create(file)
+ if err != nil {
+ return err
+ }
+ return toml.NewEncoder(f).Encode(DefaultConf())
+}