cmd

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package cmd contains all CLI commands used by the application.

Index

Constants

View Source
const (
	// MaxHashLength is the maximum hash length for md5 checksum.
	MaxHashLength = 32

	// MinHashLength is the minimum hash length for md5 checksum.
	MinHashLength = 0

	// RefLength is the default reference length.
	RefLength = 6
)
View Source
const (
	DefaultMaxSearchResults  = 10
	DefaultMemberNumber      = 13401
	DefaultConfigFilename    = ".ogma"
	DefaultLoggingLevel      = "info"
	DefaultDatastoreFilename = "ogma.db"
)

default const values for application.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func ImportListings added in v1.1.0

func ImportListings(f io.Reader, d datastore.Writer) (string, error)

ImportListings adds one to many listings to the datastore from a file.

func InitConfig added in v1.1.0

func InitConfig(fs afero.Fs, cfg string)

InitConfig sets up Viper and Logging.

func MailHash added in v1.1.0

func MailHash(m Mail, l int) string

MailHash creates a 'unique' hash of the sender, receiver, and mail date.

func NewImportListingCmd added in v1.1.0

func NewImportListingCmd() *cobra.Command

NewImportListingCmd sets up an import subcommand.

func NewImportMailCmd added in v1.1.0

func NewImportMailCmd() *cobra.Command

NewImportMailCmd sets up an import subcommand.

func NewMailCmd added in v1.1.0

func NewMailCmd() *cobra.Command

NewMailCmd creates a mail command.

func NewSearchCmd added in v1.1.0

func NewSearchCmd() *cobra.Command

NewSearchCmd creates a mail command.

func RenderMail added in v1.1.0

func RenderMail(mm []Mail, p bool) string

RenderMail returns a pretty formatted listing as table.

func RunImportListingsCmd added in v1.1.0

func RunImportListingsCmd(cmd *cobra.Command, args []string)

RunImportListingsCmd performs action associated with listings-import application command.

func RunImportMailCmd added in v1.1.0

func RunImportMailCmd(cmd *cobra.Command, args []string)

RunImportMailCmd performs action associated with mail-import application command.

func RunMailCmd added in v1.1.0

func RunMailCmd(cmd *cobra.Command, args []string)

RunMailCmd implements functionality of a mail command.

func RunSearchCmd added in v1.0.0

func RunSearchCmd(cmd *cobra.Command, args []string)

RunSearchCmd performs action associated with listings application command.

func UniqueListings added in v1.0.0

func UniqueListings(rawListings []lstg.Listing) []lstg.Listing

UniqueListings returns the passed in slice of listings with at most one of each listing. Listing order is preserved by first occurrence in initial slice.

func ValidateDate added in v1.1.0

func ValidateDate(dd string) (string, error)

ValidateDate checks date string format and parses with local time location.

Types

type Mail added in v1.1.0

type Mail struct {
	ID       int    `storm:"id,increment"`
	Ref      string `json:"reference"`
	Sender   int    `json:"sender"`
	Receiver int    `json:"receiver"`
	Date     string `json:"date"`
	Link     string `json:"link"`
}

Mail contains relevant information for correspondence.

func SearchMail added in v1.1.0

func SearchMail(member int, ds storm.Finder) ([]Mail, error)

SearchMail returns all mail records with a matching member number.

func UniqueMails added in v1.1.0

func UniqueMails(rawMails []Mail) []Mail

UniqueMails returns the passed in slice of mail with at most one of each mail. Mail order is preserved by first occurrence in initial slice.

type Mails added in v1.1.0

type Mails struct {
	Mails []Mail `json:"mails"`
}

Mails is a container for multiple mail objects.

Jump to

Keyboard shortcuts

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