diff options
author | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-25 17:37:42 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.eu> | 2020-04-25 17:37:42 +0200 |
commit | 8c134b0ece0da2d774e2bad4df35803d3c30f500 (patch) | |
tree | 1f60b14b0f01fd95401b9fe4aca4ca257602ef1c /pkg/config/config.go | |
parent | 96725ec63e12e76d6d93345d35d42b141180f4e1 (diff) | |
download | feed2imap-go-8c134b0ece0da2d774e2bad4df35803d3c30f500.tar.gz feed2imap-go-8c134b0ece0da2d774e2bad4df35803d3c30f500.tar.bz2 feed2imap-go-8c134b0ece0da2d774e2bad4df35803d3c30f500.zip |
Push global feed configuration to feeds
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r-- | pkg/config/config.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go index 83c952f..1b95f61 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -39,6 +39,15 @@ type Options struct { InclImages *bool `yaml:"include-images"` } +func (opt *Options) mergeFrom(other Options) { + if opt.MinFreq == nil { + opt.MinFreq = other.MinFreq + } + if opt.InclImages == nil { + opt.InclImages = other.InclImages + } +} + // Default feed options var DefaultFeedOptions Options @@ -111,9 +120,17 @@ func Load(path string) (*Config, error) { return nil, fmt.Errorf("while parsing: %w", err) } + cfg.pushFeedOptions() + return cfg, nil } +func (cfg *Config) pushFeedOptions() { + for _, feed := range cfg.Feeds { + feed.Options.mergeFrom(cfg.FeedOptions) + } +} + func hostname() (hostname string) { hostname, err := os.Hostname() if err != nil { |