diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-17 12:57:37 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-17 12:57:37 +0200 |
commit | 182338a22fdc5b02bf0d272b98daa4e4e6253fa2 (patch) | |
tree | 68fb0baae3ed64263c7ca2dc637b1fd512291a05 /main.go | |
download | feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.gz feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.tar.bz2 feed2imap-go-182338a22fdc5b02bf0d272b98daa4e4e6253fa2.zip |
Initial commit
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 54 |
1 files changed, 54 insertions, 0 deletions
@@ -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) + +} |