config

package
v1.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2023 License: GPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFeedOptions = Options{
	Body:        "default",
	MinFreq:     0,
	InclImages:  true,
	EmbedImages: false,
	IgnHash:     false,
	AlwaysNew:   false,
	Disable:     false,
	NoTLS:       false,
	ItemFilter:  "",
}
View Source
var DefaultGlobalOptions = GlobalOptions{
	Cache:        "feed.cache",
	Timeout:      30,
	MaxFailures:  10,
	MaxConns:     5,
	DefaultEmail: username() + "@" + Hostname(),
	Target:       Url{},
	Parts:        []string{"text", "html"},
	AutoTarget:   true,
	HtmlTemplate: "",
	TextTemplate: "",
}

Functions

func Hostname

func Hostname() (hostname string)

Hostname returns the current hostname, or 'localhost' if it cannot be determined

func TypeError

func TypeError(format string, v ...any) *yaml.TypeError

Types

type Body

type Body string

func (*Body) UnmarshalYAML

func (b *Body) UnmarshalYAML(node *yaml.Node) error

type Config

type Config struct {
	GlobalOptions `yaml:",inline"`
	FeedOptions   Options `yaml:"options"`
	Feeds         Feeds   `yaml:"-"`
}

Config holds the global configuration options and the configured feeds

func Load

func Load(path string) (*Config, error)

Load configuration from file and validate it

func WithDefault

func WithDefault() *Config

WithDefault returns a configuration initialized with default values.

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks the configuration against common mistakes

type Feed

type Feed struct {
	Name   string
	Target []string
	Url    string
	Exec   []string
	Options
}

One stored feed

type Feeds

type Feeds map[string]*Feed

Convenience type for all feeds

type GlobalOptions

type GlobalOptions struct {
	Cache        string   `yaml:"cache"`
	Timeout      int      `yaml:"timeout"`
	DefaultEmail string   `yaml:"default-email"`
	Target       Url      `yaml:"target"`
	Parts        []string `yaml:"parts"`
	MaxFailures  int      `yaml:"max-failures"`
	MaxConns     int      `yaml:"max-imap-connections"`
	AutoTarget   bool     `yaml:"auto-target"`
	HtmlTemplate string   `yaml:"html-template"`
	TextTemplate string   `yaml:"text-template"`
}

GlobalOptions are not feed specific

func (GlobalOptions) WithPartHtml

func (opt GlobalOptions) WithPartHtml() bool

WithPartHtml marks whether 'html' part should be included in mails

func (GlobalOptions) WithPartText

func (opt GlobalOptions) WithPartText() bool

WithPartText marks whether 'text' part should be included in mails

type Map

type Map map[string]any

Map is a convenience type for the non-mapped configuration options Mostly used for legacy options

type Options

type Options struct {
	MinFreq     int    `yaml:"min-frequency"`
	InclImages  bool   `yaml:"include-images"`
	EmbedImages bool   `yaml:"embed-images"`
	Disable     bool   `yaml:"disable"`
	IgnHash     bool   `yaml:"ignore-hash"`
	AlwaysNew   bool   `yaml:"always-new"`
	Reupload    bool   `yaml:"reupload-if-updated"`
	NoTLS       bool   `yaml:"tls-no-verify"`
	ItemFilter  string `yaml:"item-filter"`
	Body        Body   `yaml:"body"`
}

Options are feed specific NB: Always specify a yaml name, as it is later used in processing

type Url added in v0.4.0

type Url struct {
	Scheme   string `yaml:"scheme"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Host     string `yaml:"host"`
	Port     string `yaml:"port"`
	Root     string `yaml:"root"`
}

func (Url) BaseUrl added in v1.2.0

func (u Url) BaseUrl() Url

func (*Url) CommonBaseUrl added in v1.2.0

func (u *Url) CommonBaseUrl(other Url) bool

func (*Url) Empty added in v0.4.0

func (u *Url) Empty() bool

func (*Url) EmptyRoot added in v1.2.0

func (u *Url) EmptyRoot() bool

func (*Url) ForceTLS added in v0.4.0

func (u *Url) ForceTLS() bool

func (*Url) HostPort added in v0.4.0

func (u *Url) HostPort() string

func (*Url) RootPath added in v1.2.0

func (u *Url) RootPath() []string

func (Url) String added in v0.4.0

func (u Url) String() string

func (*Url) UnmarshalYAML added in v0.4.0

func (u *Url) UnmarshalYAML(value *yaml.Node) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL