tui

package
v8.0.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2017 License: MIT Imports: 10 Imported by: 1

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, prompt string) interface{}

Types

type Cell added in v0.4.1

type Cell []string

func ParseCell added in v0.4.1

func ParseCell(s string) Cell

func (Cell) Height added in v0.4.1

func (c Cell) Height() int

func (Cell) Line added in v0.4.1

func (c Cell) Line(i int) string

func (Cell) Width added in v0.4.1

func (c Cell) Width() int

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 Grid added in v0.4.1

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

func NewGrid added in v0.4.1

func NewGrid(header ...string) Grid

func NewIndexedGrid added in v0.4.1

func NewIndexedGrid(header ...string) Grid

func (*Grid) Columns added in v0.4.1

func (t *Grid) Columns() int

func (Grid) Height added in v0.4.1

func (t Grid) Height() int

func (*Grid) Line added in v0.4.1

func (t *Grid) Line(n int) string

func (*Grid) Lines added in v0.4.1

func (t *Grid) Lines() []string

func (*Grid) Row added in v0.4.1

func (t *Grid) Row(vv ...interface{})

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)

type Row added in v0.4.1

type Row []Cell

func ParseRow added in v0.4.1

func ParseRow(ss ...string) Row

func (Row) Height added in v0.4.1

func (r Row) Height() int

func (Row) Width added in v0.4.1

func (r Row) Width() int

type Table

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

func NewTable

func NewTable(header ...string) Table

func (*Table) Object added in v0.4.1

func (t *Table) Object(i int) interface{}

func (*Table) Output

func (t *Table) Output(out io.Writer)

func (*Table) OutputWithIndices added in v0.4.1

func (t *Table) OutputWithIndices(out io.Writer)

func (*Table) Row

func (t *Table) Row(object interface{}, cells ...interface{})

func (*Table) Rows added in v0.4.1

func (t *Table) Rows() int

Jump to

Keyboard shortcuts

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