ui

package
v0.0.0-...-3814ceb Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2020 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StdColor   = color.New()            // Default color.
	ErrorColor = color.New(color.FgRed) // Errors.

	SuccColor     = color.New(color.FgGreen)             // Successful stuff.
	FailColor     = color.New(color.FgRed)               // Failed stuff.
	GrayColor     = color.New(color.Faint)               // Padding and disabled stuff.
	ValueColor    = color.New(color.FgCyan)              // Values of all kinds.
	ExtraColor    = color.New(color.FgCyan, color.Faint) // Extra annotations for values.
	ExtraKeyColor = color.New(color.Faint)               // Keys inside extra annotations.

	TypeColor    = color.New(color.FgYellow) // Syntax: Types.
	CommentColor = color.New(color.FgBlue)   // Syntax: Comments.
)

Functions

func Dump

func Dump(w io.Writer, v interface{})

func StrWidth

func StrWidth(s string) (n int)

StrWidth returns the actual width of the string.

func ValidateSummary

func ValidateSummary(trendColumns []string) error

ValidateSummary checks if passed trend columns are valid for use in the summary output.

Types

type ErrInvalidStat

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

ErrInvalidStat represents an invalid trend column stat

func (ErrInvalidStat) Error

func (e ErrInvalidStat) Error() string

type Field

type Field interface {
	GetKey() string                        // Key for the data map.
	GetLabel() string                      // Label to print as the prompt.
	GetLabelExtra() string                 // Extra info for the label, eg. defaults.
	GetContents(io.Reader) (string, error) // Read the field contents from the supplied reader

	// Sanitize user input and return the field's native type.
	Clean(s string) (interface{}, error)
}

A Field in a form.

type Form

type Form struct {
	Banner string
	Fields []Field
}

A Form used to handle user interactions.

func (Form) Run

func (f Form) Run(r io.Reader, w io.Writer) (map[string]interface{}, error)

Run executes the form against the specified input and output.

type PasswordField

type PasswordField struct {
	Key   string
	Label string
	Min   int
}

PasswordField masks password input

func (PasswordField) Clean

func (f PasswordField) Clean(s string) (interface{}, error)

Clean just checks if the minimum length is exceeded, it doesn't trim the string!

func (PasswordField) GetContents

func (f PasswordField) GetContents(r io.Reader) (string, error)

GetContents simply reads a string in cleartext from the supplied reader

func (PasswordField) GetKey

func (f PasswordField) GetKey() string

GetKey returns the field's key

func (PasswordField) GetLabel

func (f PasswordField) GetLabel() string

GetLabel returns the field's label

func (PasswordField) GetLabelExtra

func (f PasswordField) GetLabelExtra() string

GetLabelExtra doesn't return anything so we don't expose the current password

type StringField

type StringField struct {
	Key     string
	Label   string
	Default string

	// Length constraints.
	Min, Max int
}

StringField is just a simple field for reading cleartext strings

func (StringField) Clean

func (f StringField) Clean(s string) (interface{}, error)

Clean trims the spaces in the string and checks for min and max length

func (StringField) GetContents

func (f StringField) GetContents(r io.Reader) (string, error)

GetContents simply reads a string in cleartext from the supplied reader It's compllicated and doesn't use t he bufio utils because we can't read ahead of the newline and consume more of the stdin, because we'll mess up the next form field

func (StringField) GetKey

func (f StringField) GetKey() string

GetKey returns the field's key

func (StringField) GetLabel

func (f StringField) GetLabel() string

GetLabel returns the field's label

func (StringField) GetLabelExtra

func (f StringField) GetLabelExtra() string

GetLabelExtra returns the field's default value

type Summary

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

Summary handles test summary output

func NewSummary

func NewSummary(cols []string) *Summary

NewSummary returns a new Summary instance, used for writing a summary/report of the test metrics data.

func (*Summary) SummarizeMetrics

func (s *Summary) SummarizeMetrics(w io.Writer, indent string, data SummaryData)

SummarizeMetrics creates a summary of provided metrics and writes it to w.

func (*Summary) SummarizeMetricsJSON

func (s *Summary) SummarizeMetricsJSON(w io.Writer, data SummaryData) error

SummarizeMetricsJSON summarizes a dataset in JSON format.

type SummaryData

type SummaryData struct {
	Metrics   map[string]*stats.Metric
	RootGroup *lib.Group
	Time      time.Duration
	TimeUnit  string
}

SummaryData represents data passed to Summary.SummarizeMetrics

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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