config

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

* finish: verify/clean/finish config data * * finishers defined in dedicated file *

* finisher: interfaces for use by finisher functions * * any finisher function is expected to return a struct abiding by the ConfigFinish interface *

* finishers: slice of ConfigFinish-returning closures * * verify/clean/finish config data here *

Index

Constants

This section is empty.

Variables

View Source
var (
	// config flags
	//
	// defaults *may* be specified here (and to be modifiable prior to invocation of Define)
	Interface string           // interface
	Tool      string           // ndt or ookla
	PingType  string           // icmp or udp
	MaxTTL    int              // maximum TTL until which to send pings
	DirectHop int              // hop to ping directly by icmp echo
	OutPath   string = "data/" // out path/directory (may be directory/, file or -)
	TShark    bool             // use tshark
	IdleTime  int              // idle time in seconds
	Force     bool             // whether to confirm
	Quiet     bool             // silence logging
	Terse     bool             // terse rtt metadata

	// internal config
	WorkDir     string
	TempWorkDir string

	Timestamp   time.Time
	InterfaceIP []net.IP
	ServerIP    net.IP

	NAME    string
	VERSION string
)

Functions

func Define

func Define()

func GetFilePath added in v0.1.2

func GetFilePath(fileName string) string

func Parse

func Parse() error

func ShouldArchive added in v0.1.2

func ShouldArchive() bool

func Teardown added in v0.1.2

func Teardown()

Types

type ConfigEval added in v0.1.2

type ConfigEval struct {
	Label  string // config label
	Value  string // config value
	ErrorM string // config error message (if any)
}

ConfigEval

Standard finishers evaluate user-provided configuration, returning a standard log message for valid values or a value-dependent error message for invalid values

The user is not prompted for confirmation; errors are returned immediately.

func (ConfigEval) Error added in v0.1.2

func (err ConfigEval) Error() string

func (ConfigEval) Log added in v0.1.2

func (err ConfigEval) Log() string

func (ConfigEval) Notice added in v0.1.2

func (err ConfigEval) Notice() string

func (ConfigEval) Prompt added in v0.1.2

func (err ConfigEval) Prompt() string

type ConfigFinish added in v0.1.2

type ConfigFinish interface {
	Log() string
	Notice() string
	Prompt() string
	Error() string
}

ConfigFinish: interface used by all finishers

type Confirmation added in v0.1.2

type Confirmation struct {
	Label   string // confirmation label
	NoticeT string // template of above to be printed once
}

Confirmation

Alternatively, finishers may prompt the user for confirmation of their configuration. This ConfigFinish is returned as an error only if the user rejects the confirmation.

A notice is optionally printed (rather than logged), whereby verbose information may be printed once, above the confirmation dialog.

The error message for a Confirmation is an empty string, as no additional information need be communicated to the user.

func (Confirmation) Error added in v0.1.2

func (err Confirmation) Error() string

No need for Error

func (Confirmation) Log added in v0.1.2

func (err Confirmation) Log() string

func (Confirmation) Notice added in v0.1.2

func (err Confirmation) Notice() string

Notice to print

interpolate Label into NoticeT to reduce repetition

func (Confirmation) Prompt added in v0.1.2

func (err Confirmation) Prompt() string

Label is treated as the Prompt

Jump to

Keyboard shortcuts

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