aboutsummaryrefslogtreecommitdiffstats
path: root/src/c_init.go
diff options
context:
space:
mode:
authorJoe <rbo@gmx.us>2024-05-16 20:20:20 +0200
committerJoe <rbo@gmx.us>2024-05-16 20:20:20 +0200
commitbdf8e0b2e16de39a7fb7f3bf8f51605d542e19c9 (patch)
tree003492335c1b93c7fae588c75f6117c7840b86fc /src/c_init.go
parentcoool (diff)
downloadhardflip-bdf8e0b2e16de39a7fb7f3bf8f51605d542e19c9.tar.gz
hardflip-bdf8e0b2e16de39a7fb7f3bf8f51605d542e19c9.tar.bz2
hardflip-bdf8e0b2e16de39a7fb7f3bf8f51605d542e19c9.tar.xz
hardflip-bdf8e0b2e16de39a7fb7f3bf8f51605d542e19c9.tar.zst
hardflip-bdf8e0b2e16de39a7fb7f3bf8f51605d542e19c9.zip
fucking great
Diffstat (limited to 'src/c_init.go')
-rw-r--r--src/c_init.go27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/c_init.go b/src/c_init.go
index 0bc37be..58b71c5 100644
--- a/src/c_init.go
+++ b/src/c_init.go
@@ -166,6 +166,18 @@ func c_write_options(file string, opts HardOpts, load_err *[]error) {
}
}
+func c_write_styles(file string, opts HardStyle, load_err *[]error) {
+ data, err := yaml.Marshal(opts)
+ if err != nil {
+ *load_err = append(*load_err, err)
+ return
+ }
+ err = os.WriteFile(file, data, 0644)
+ if err != nil {
+ *load_err = append(*load_err, err)
+ }
+}
+
func c_get_options(dir string, load_err *[]error) HardOpts {
opts := HardOpts{}
file := dir + "/" + CONF_FILE_NAME
@@ -184,6 +196,17 @@ func c_get_options(dir string, load_err *[]error) HardOpts {
}
func c_get_styles(dir string, load_err *[]error) HardStyle {
- // TODO: here
- return DEFAULT_STYLE
+ styles := HardStyle{}
+ file := dir + "/" + STYLE_FILE_NAME
+
+ if _, err := os.Stat(file); os.IsNotExist(err) {
+ c_write_styles(file, DEFAULT_STYLE, load_err)
+ return DEFAULT_STYLE
+ }
+ styles, err := c_parse_styles(file)
+ if err != nil {
+ *load_err = append(*load_err, err)
+ return DEFAULT_STYLE
+ }
+ return styles
}