tui

package
v8.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm added in v0.4.1

func Confirm(prompt string) bool

func FieldIsBoolean added in v0.4.1

func FieldIsBoolean(name string, value string) (interface{}, error)

func FieldIsOptional

func FieldIsOptional(name string, value string) (interface{}, error)

func FieldIsRequired

func FieldIsRequired(name string, value string) (interface{}, error)
func Menu(intro string, t *table.Table, prompt string) interface{}

Types

type ComplexValue added in v0.4.1

type ComplexValue interface {
	HumanReadable() string        // Used to display information to the human operator
	MachineReadable() interface{} // Used for API requests
}

A ComplexValue represents some thing that needs to be displayed one way to a human operator, and another way to a machine (API)

type Field

type Field struct {
	Label     string
	Name      string
	ShowAs    string
	Value     interface{}
	Processor FieldProcessor
	Hidden    bool
}

A Field represents a single piece of information that the operator must enter, usually in the larger context of a Form. Each Field has its own prompt label, internal field name, stored value and processor function for validation / data manipulation.

func (*Field) OrDefault added in v0.4.1

func (field *Field) OrDefault(v string) string

func (*Field) Prompt

func (field *Field) Prompt() error

func (*Field) PromptString added in v0.4.1

func (field *Field) PromptString() string

type FieldProcessor added in v0.4.1

type FieldProcessor func(name string, value string) (interface{}, error)

A FieldProcessor is any function that validates, transforms, or replaces a value entered by the operator into a different value. For example, entering a duration as a string, i.e. "4d", might result in a FieldProcessor creating a Duration object representing four days worth of time.

type Form

type Form struct {
	Fields []*Field
}

A Form represents a set of Fields that an operator must fill out in order to change some piece of data elsewhere inside of SHIELD.

func NewForm

func NewForm() *Form

NewForm creates and returns a pointer to a new Form object.

func (*Form) BuildContent

func (f *Form) BuildContent() (string, error)

func (*Form) Confirm added in v0.4.1

func (f *Form) Confirm(prompt string) bool

func (*Form) GetField

func (f *Form) GetField(name string) *Field

GetField retrieves the reference to the Field with the Name attribute given to this function. Returns nil if no such Field was found.

func (*Form) NewField

func (f *Form) NewField(label string, name string, value interface{}, showas string, fn FieldProcessor) (*Field, error)

NewField appends a new Field to the Form.

func (*Form) Show

func (f *Form) Show() error

type Report

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

func NewReport

func NewReport() Report

func (*Report) Add

func (r *Report) Add(key string, value string)

func (*Report) Break

func (r *Report) Break()

func (*Report) Output

func (r *Report) Output(out io.Writer)

Jump to

Keyboard shortcuts

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