aboutsummaryrefslogtreecommitdiff
path: root/pkg/config
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-02 16:48:51 +0200
committerRené 'Necoro' Neumann <necoro@necoro.eu>2020-05-02 16:48:51 +0200
commitd75bbcf9a7fe589f119b103d357ffa874008ab07 (patch)
tree9f5b27e5e9c48e3d0e5acd5bf6f16f60f47b6b29 /pkg/config
parent3e219c232c0bb4a64f615c599473c959691e6319 (diff)
downloadfeed2imap-go-d75bbcf9a7fe589f119b103d357ffa874008ab07.tar.gz
feed2imap-go-d75bbcf9a7fe589f119b103d357ffa874008ab07.tar.bz2
feed2imap-go-d75bbcf9a7fe589f119b103d357ffa874008ab07.zip
Option 'body'
Diffstat (limited to '')
-rw-r--r--pkg/config/body.go35
-rw-r--r--pkg/config/config.go2
2 files changed, 37 insertions, 0 deletions
diff --git a/pkg/config/body.go b/pkg/config/body.go
new file mode 100644
index 0000000..d9957d5
--- /dev/null
+++ b/pkg/config/body.go
@@ -0,0 +1,35 @@
+package config
+
+import (
+ "fmt"
+
+ "gopkg.in/yaml.v3"
+
+ "github.com/Necoro/feed2imap-go/pkg/util"
+)
+
+type Body string
+
+var validBody = []string{"default", "both", "content", "description"}
+
+func (b *Body) UnmarshalYAML(node *yaml.Node) error {
+ var val string
+ if err := node.Decode(&val); err != nil {
+ return err
+ }
+
+ if val == "" {
+ val = "default"
+ }
+
+ if !util.StrContains(validBody, val) {
+ return TypeError("line %d: Invalid value for 'body': %q", node.Line, val)
+ }
+
+ *b = Body(val)
+ return nil
+}
+
+func TypeError(format string, v ...interface{}) *yaml.TypeError {
+ return &yaml.TypeError{Errors: []string{fmt.Sprintf(format, v...)}}
+}
diff --git a/pkg/config/config.go b/pkg/config/config.go
index d1cd4c9..dfd3d0e 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -44,10 +44,12 @@ type Options struct {
IgnHash bool `yaml:"ignore-hash"`
AlwaysNew bool `yaml:"always-new"`
NoTLS bool `yaml:"tls-no-verify"`
+ Body Body `yaml:"body"`
}
// Default feed options
var DefaultFeedOptions = Options{
+ Body: "default",
MinFreq: 1,
InclImages: true,
EmbedImages: false,