aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-17 12:57:37 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-04-17 12:57:37 +0200
commit182338a22fdc5b02bf0d272b98daa4e4e6253fa2 (patch)
tree68fb0baae3ed64263c7ca2dc637b1fd512291a05 /main.go
downloadfeed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.gz
feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.bz2
feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.zip
Initial commit
Diffstat (limited to 'main.go')
-rw-r--r--main.go54
1 files changed, 54 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..9f20203
--- /dev/null
+++ b/main.go
@@ -0,0 +1,54 @@
+package main
+
+import (
+ "flag"
+ "fmt"
+ "io/ioutil"
+ "log"
+
+ "gopkg.in/yaml.v2"
+)
+
+var cfg = flag.String("f", "config.yml", "configuration file")
+
+type ConfigMap map[string]interface{}
+
+type Feed struct {
+ Name string
+ Url string
+ MinFreq int `yaml:"min-frequency"`
+ ConfigMap `yaml:",inline"`
+}
+
+type Group struct {
+ Group string
+ Feeds []GroupFeed
+}
+
+type GroupFeed struct {
+ Target string
+ Feed `yaml:",inline"`
+ Group `yaml:",inline"`
+}
+
+type Yaml struct {
+ GlobalConfig ConfigMap `yaml:",inline"`
+ Feeds []GroupFeed
+}
+
+func main() {
+ log.Print("Starting up...")
+ flag.Parse()
+
+ log.Printf("Reading configuration file '%s'", *cfg)
+ buf, err := ioutil.ReadFile(*cfg)
+ if err != nil {
+ msg := fmt.Sprint("No file found: ", *cfg)
+ panic(msg)
+ }
+
+ var m Yaml
+ yaml.Unmarshal(buf, &m)
+ fmt.Printf("--- m:\n%+v\n\n", m)
+
+}