configfile

package
v0.0.0-...-da9a3f8 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package configfile contains the logic to read a list of source URLs, along with any (optional) configuration-directives.

A configuration file looks like this:

https://example.com/
 - foo:bar

https://example.org/
https://example.net/
# comment

It is assumed lines contain URLs, but anything prefixed with a "-" is taken to be a parameter using a colon-deliminator.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigFile

type ConfigFile struct {
	// contains filtered or unexported fields
}

ConfigFile contains our state.

func New

func New() *ConfigFile

New creates a new configuration-file reader.

func NewWithPath

func NewWithPath(file string) *ConfigFile

NewWithPath creates a configuration-file reader, using the given file as a source. This is primarily used for testing.

func (*ConfigFile) Add

func (c *ConfigFile) Add(uris ...string)

Add appends the given URIs to the config-file

You must call `Save` if you wish this removal to be persisted.

func (*ConfigFile) Delete

func (c *ConfigFile) Delete(url string)

Delete removes an entry from our list of feeds.

You must call `Save` if you wish this removal to be persisted.

func (*ConfigFile) Parse

func (c *ConfigFile) Parse() ([]Feed, error)

Parse returns the entries from the config-file

func (*ConfigFile) Path

func (c *ConfigFile) Path() string

Path returns the path to the configuration-file.

func (*ConfigFile) Save

func (c *ConfigFile) Save() error

Save persists our list of feeds/options to disk.

type Feed

type Feed struct {
	// URL is the URL of an Atom/RSS feed.
	URL string

	// Options contains a collection of any optional parameters
	// which have been read after an URL
	Options []Option
}

Feed is an entry which is read from our configuration-file.

A feed consists of an URL pointing to an Atom/RSS feed, as well as an optional set of parameters which are specific to that feed.

type Option

type Option struct {
	// Name holds the name of the configuration option.
	Name string

	// Value contains the specified value of the configuration option.
	Value string
}

Option contain options which are used on a per-feed basis.

We could use a map, but that would mean that each named option could only be used once - and we want to allow multiple "exclude" values for example.

Jump to

Keyboard shortcuts

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