config

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package config provides types and functions to collect, validate and apply user-provided settings.

Index

Constants

This section is empty.

Variables

View Source
var Usage = func() {
	fmt.Fprintf(flag.CommandLine.Output(), "%s %s\n%s\n\n", myAppName, version, myAppURL)
	fmt.Fprintf(flag.CommandLine.Output(), "Usage of %s:\n", os.Args[0])
	flag.PrintDefaults()
}

Usage is a custom override for the default Help text provided by the flag package. Here we prepend some additional metadata to the existing output.

Functions

func Branding

func Branding(msg string) func() string

Branding accepts a message and returns a function that concatenates that message with version information. This function is intended to be called as a final step before application exit after any other output has already been emitted.

func Version

func Version() string

Version emits application name, version and repo location.

Types

type Config

type Config struct {

	// Folders to check for mail. This value is provided a comma-separated
	// list.
	Folders multiValueFlag

	// Username represents the account used to login to the remote mail
	// server. This is often in the form of an email address.
	Username string

	// Password is the remote mail server account password.
	Password string

	// Server is the fully-qualified domain name of the remote mail server.
	Server string

	// Port is the TCP port used to connect to the remote server. This is
	// commonly 993.
	Port int

	// LoggingLevel is the supported logging level for this application.
	LoggingLevel string

	// EmitBranding controls whether "generated by" text is included at the
	// bottom of application output. This output is included in the Nagios
	// dashboard and notifications. This output may not mix well with branding
	// output from other tools such as atc0005/send2teams which also insert
	// their own branding output.
	EmitBranding bool
}

Config represents the application configuration as specified via command-line flags.

func New

func New() *Config

New is a factory function that produces a new Config object based on user provided flag and config file values.

func (Config) Validate

func (c Config) Validate() error

Validate verifies all Config struct fields have been provided acceptable values.

Jump to

Keyboard shortcuts

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