summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-11 11:22:47 +0530
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-11 11:22:47 +0530
commit856f66808b913baff13c815daec3cdde7121e3bd (patch)
tree60feca35e702d20a0ec8da208b6b59926470bf31 /config
downloadlegit-856f66808b913baff13c815daec3cdde7121e3bd.tar.gz
legit-856f66808b913baff13c815daec3cdde7121e3bd.tar.bz2
legit-856f66808b913baff13c815daec3cdde7121e3bd.zip
all: init
Diffstat (limited to '')
-rw-r--r--config.yaml7
-rw-r--r--config/config.go35
2 files changed, 42 insertions, 0 deletions
diff --git a/config.yaml b/config.yaml
new file mode 100644
index 0000000..fad606a
--- /dev/null
+++ b/config.yaml
@@ -0,0 +1,7 @@
+git:
+ scanPath: /home/icy/code/tmp
+template:
+ dir: ./templates
+meta:
+ title: git good
+ description: i think it's a skill issue
diff --git a/config/config.go b/config/config.go
new file mode 100644
index 0000000..71bc8dc
--- /dev/null
+++ b/config/config.go
@@ -0,0 +1,35 @@
+package config
+
+import (
+ "fmt"
+ "os"
+
+ "gopkg.in/yaml.v3"
+)
+
+type Config struct {
+ Git struct {
+ ScanPath string `yaml:"scanPath"`
+ } `yaml:"git"`
+ Template struct {
+ Dir string `yaml:"dir"`
+ } `yaml:"template"`
+ Meta struct {
+ Title string `yaml:"title"`
+ Description string `yaml:"description"`
+ } `yaml:"meta"`
+}
+
+func Read(f string) (*Config, error) {
+ b, err := os.ReadFile(f)
+ if err != nil {
+ return nil, fmt.Errorf("reading config: %w", err)
+ }
+
+ c := Config{}
+ if err := yaml.Unmarshal(b, &c); err != nil {
+ return nil, fmt.Errorf("parsing config: %w", err)
+ }
+
+ return &c, nil
+}