alias

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2020 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetAliases

func SetAliases(a Aliases) func(*Table) error

SetAliases is a Table option for setting the aliases.

func SetColumns

func SetColumns(c []string) func(*Table) error

SetColumns is a Table option for setting the columns to display.

func SetHeaders

func SetHeaders(h bool) func(*Table) error

SetHeaders is a Table option for setting the option to display headers.

func SetNumbers

func SetNumbers(n bool) func(*Table) error

SetNumbers is a Table option for setting the option to display numbers.

func SetTableWriter

func SetTableWriter(w io.Writer) func(*Table) error

SetTableWriter is a Table option for setting the writer.

func TStoString

func TStoString(ts time.Time) string

TStoString converts a timestamp to RFC3339 format string. If the time is the zero time, it is rendered as an empty string. The string is returned.

Types

type Alias

type Alias struct {
	Alias          string
	Domain         string
	EmailAddresses []string `column:"Email Address(es)"`
	Description    string
	Suspended      bool
	CreatedTS      time.Time `column:"Created Time"`
	ModifiedTS     time.Time `column:"Modified Time"`
	SuspendedTS    time.Time `column:"Suspended Time"`
}

Alias represents the state necessary for an email alias.

func (Alias) Equal

func (a Alias) Equal(b Alias) bool

Equal checks for equality between two Alias types. All fields are checked for equality and all of them must match. A true value is returned when all fields match. When a field does not match, an error specifying the mismatched field is returned.

func (Alias) Fields

func (a Alias) Fields() []string

Fields returns a slice of strings composed of the field names of the Alias struct.

func (Alias) Filter

func (a Alias) Filter(filter Filter, matchAnyRegexp bool) bool

Filter applies the fields in a Filter struct against the fields on an Alias struct. If all Alias fields match against the Filter struct, then true is returned. Otherwise, false is returned.

func (Alias) Key

func (a Alias) Key() string

Key returns a key name for maps based on the Alias and Domain fields which should be unique.

func (Alias) StripData

func (a Alias) StripData(fields []string) (Alias, error)

StripData takes a list for field names as a string slice. Any field name not present in the string slice has it's field value set to the zero value. An Alias with all the specified values still set is returned as well as an error if there was a problem setting a field value.

func (Alias) UnifiedDiff

func (a Alias) UnifiedDiff(b Alias) string

UnifiedDiff returns a unified text diff of both Alias(es). Otherwise it returns an empty string.

type Aliases

type Aliases []Alias

Aliases represents a slice of Alias structs.

func (Aliases) Diff

func (s Aliases) Diff(s2 Aliases) Aliases

Diff is the difference between two slices of Alias. A slice of Alias of the elements not in common are returned and are sorted.

func (Aliases) Equal

func (s Aliases) Equal(s2 Aliases) bool

Equal checks for equality between two Aliases types.

func (Aliases) Len

func (s Aliases) Len() int

func (Aliases) Less

func (s Aliases) Less(i, j int) bool

func (Aliases) StripData

func (s Aliases) StripData(names []string) (Aliases, error)

StripData takes a list for field names as a string slice. Any field name not present in the string slice has it's field value set to the zero value. This is applied to all elements of the Aliases type. The stripped data is returned as well as an error if there was a problem setting a field value.

func (Aliases) Swap

func (s Aliases) Swap(i, j int)

func (Aliases) ToMap

func (s Aliases) ToMap() AliasesMap

ToMap transforms an Aliases type to an AliasesMap type.

type AliasesMap

type AliasesMap map[string]Alias

AliasesMap represents a map of Alias structs. The key is based on the Alias and Domain fields of the Alias structs.

func (AliasesMap) Add

func (m AliasesMap) Add(a Alias)

Add adds an Alias to an AliasMap type.

func (AliasesMap) Del

func (m AliasesMap) Del(a Alias)

Del removes an Alias from an AliasMap type.

func (AliasesMap) ToSlice

func (m AliasesMap) ToSlice() Aliases

ToSlice transforms an AliasesMap type to an Aliases type. The returned Aliases type is sorted.

type Filter

type Filter struct {
	Alias            *regexp.Regexp
	Domain           *regexp.Regexp
	EmailAddress     *regexp.Regexp
	Description      *regexp.Regexp
	ExcludeSuspended bool
	ExcludeEnabled   bool
}

Filter is the settings for filtering aliases. There are regexps for aliases, domains, email addresses and descriptions. By default enabled and suspended aliases will be included. There are options to exclude enabled and/or suspended aliases.

type Table

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

Table represents the state necessary to render a table of Aliases to an io.Writer.

func NewTable

func NewTable(options ...func(*Table) error) (*Table, error)

NewTable returns a new *Table instance.

func (*Table) Render

func (t *Table) Render()

Render outputs a table of aliases.

Jump to

Keyboard shortcuts

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