diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-19 22:00:56 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-19 22:00:56 +0200 |
commit | 9b982a82c150c65a5f72c9b548053553b2c3b0fb (patch) | |
tree | 81b203c9500e345710ac26dea6eda690b936d6ff /internal/config/yaml.go | |
parent | fe3d64998545eb4fbddb26e79eefeb3fa89bbbdd (diff) | |
download | feed2imap-go-9b982a82c150c65a5f72c9b548053553b2c3b0fb.tar.gz feed2imap-go-9b982a82c150c65a5f72c9b548053553b2c3b0fb.tar.bz2 feed2imap-go-9b982a82c150c65a5f72c9b548053553b2c3b0fb.zip |
Store path as array -- the delimiter is not always '.'
Diffstat (limited to 'internal/config/yaml.go')
-rw-r--r-- | internal/config/yaml.go | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/internal/config/yaml.go b/internal/config/yaml.go index 8c40107..80fb383 100644 --- a/internal/config/yaml.go +++ b/internal/config/yaml.go @@ -27,7 +27,7 @@ func (grpFeed *configGroupFeed) isGroup() bool { } func (grpFeed *configGroupFeed) isFeed() bool { - return grpFeed.Feed != Feed{} + return grpFeed.Feed.Name != "" || grpFeed.Feed.Url != "" } func (grpFeed *configGroupFeed) target() string { @@ -51,20 +51,21 @@ func parse(buf []byte) (config, error) { return parsedCfg, nil } -func appTarget(target, app string) string { - if target == "" { - return app - } - - if app == "" { +func appTarget(target []string, app string) []string { + switch { + case len(target) == 0 && app == "": + return []string{} + case len(target) == 0: + return []string{app} + case app == "": return target + default: + return append(target, app) } - - return target + "." + app } // Parse the group structure and populate the `Target` fields in the feeds -func buildFeeds(cfg []configGroupFeed, target string, feeds Feeds) error { +func buildFeeds(cfg []configGroupFeed, target []string, feeds Feeds) error { for idx := range cfg { f := &cfg[idx] // cannot use `_, f := range cfg` as it returns copies(!), but we need the originals target := appTarget(target, f.target()) |