common

package
v0.0.0-...-6d492ca Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2021 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

configuration.go: module for managing message properties * * Copyright (C) 2016-2018 Clemens Fries <github-lettersnail@xenoworld.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>.

consts.go: global constants * * Copyright (C) 2016-2018 Clemens Fries <github-lettersnail@xenoworld.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>.

message.go: module for managing message information * * Copyright (C) 2016-2018 Clemens Fries <github-lettersnail@xenoworld.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>.

util.go: various utility functions * * Copyright (C) 2016-2018 Clemens Fries <github-lettersnail@xenoworld.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	TIME_FORMAT     = "15:04"
	DATE_FORMAT     = "2006-01-02"
	DATETIME_FORMAT = DATE_FORMAT + " " + TIME_FORMAT

	DIR_TODO   = "todo"
	DIR_DRAFTS = "drafts"
	DIR_ERRORS = "errors"
	DIR_DONE   = "done"

	CMD_USAGE = "usage"
	CMD_RUN   = "run"

	CONF_WORKDIR         = "workdir"
	CONF_DATE            = "date"
	CONF_DAYS            = "days"
	CONF_SUBJECT         = "subject"
	CONF_TO              = "to"
	CONF_FROM            = "from"
	CONF_REPLY_TO        = "reply-to"
	CONF_CC              = "cc"
	CONF_BCC             = "bcc"
	CONF_CONFIG_FILENAME = "config"
	CONF_SMTP_SERVER     = "server"
	CONF_SMTP_PORT       = "port"
	CONF_SMTP_INSECURE   = "insecure"
	CONF_NOT_BEFORE      = "not-before"
	CONF_NOT_AFTER       = "not-after"
)

Project wide constants.

Variables

This section is empty.

Functions

func ParseTime

func ParseTime(datetime string) (time.Time, error)

Parse a time which may either be just a date or a date with time.

func SplitMessage

func SplitMessage(text []string) ([]string, []string)

Split a text in two parts on the first blank line.

Types

type Configuration

type Configuration struct {
	Data map[string]string
}

func NewConfiguration

func NewConfiguration() *Configuration

func (*Configuration) DumpConfig

func (c *Configuration) DumpConfig() []string

Dump the configuration as strings in the form `key: value`.

func (*Configuration) Get

func (c *Configuration) Get(key string) string

func (*Configuration) Load

func (c *Configuration) Load(text []string)

Load configuration from an array of strings in the form `key: value`.

func (*Configuration) MergeWith

func (c *Configuration) MergeWith(src *Configuration)

Merge the `src` configuration into this configuration.

func (*Configuration) MergeWithDocOptArgs

func (c *Configuration) MergeWithDocOptArgs(cmd string, args *map[string]interface{})

Merge arguments from the DocOpt parser into a configuration map. All arguments that are not `nil` and start with "--" will be merged. Booleans will be converted to strings.

func (*Configuration) MergeWithIni

func (c *Configuration) MergeWithIni(cmd string)

Merges the "default" and the "cmd" section from CONF_CONFIG_FILENAME.

func (*Configuration) Set

func (c *Configuration) Set(key string, value string)

type Message

type Message struct {
	Conf Configuration
	Body []string
	Name string
}

func NewMessage

func NewMessage() *Message

Create a new, empty Message.

func NewMessageFromFile

func NewMessageFromFile(path string) (Message, error)

Construct new Message from the given file.

func (*Message) Get

func (m *Message) Get(key string) string

Return the specified configuration key's value.

func (*Message) Verify

func (m *Message) Verify() []error

Verify if a message has all necessary parameters. We need at least to, from, subject, and date. This will also verify optional address lists, etc.

func (*Message) WriteToFile

func (m *Message) WriteToFile(file string) error

Write a message to a file, such that it could be loaded again.

type Messages

type Messages []Message

Supporting sort.Interface.

func NewMessagesFromDirectory

func NewMessagesFromDirectory(dir string) Messages

Load all messages in the given directory.

func (Messages) Len

func (m Messages) Len() int

func (Messages) Less

func (m Messages) Less(i, j int) bool

func (Messages) Swap

func (m Messages) Swap(i, j int)

Jump to

Keyboard shortcuts

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