ui

package
v0.0.0-...-5d27ecb Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BasicUI

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

BasicUI is an implementation of UI that just outputs to the given writer.

func NewBasicUI

func NewBasicUI(stdin io.Reader, stdout, stderr io.Writer) *BasicUI

NewBasicUI creates a new BasicUI with dependencies.

func (*BasicUI) Ask

func (u *BasicUI) Ask(query string) (string, error)

Ask asks the user for input using the given query. The response is returned as the given string, or an error.

func (*BasicUI) AskSecret

func (u *BasicUI) AskSecret(query string) (string, error)

AskSecret asks the user for input using the given query, but does not echo the keystrokes to the terminal.

func (*BasicUI) Error

func (u *BasicUI) Error(message string)

Error is used for any error messages that might appear on standard error.

func (*BasicUI) Info

func (u *BasicUI) Info(message string)

Info is called for information related to the previous output. In general this may be the exact same as Output, but this gives UI implementors some flexibility with output formats.

func (*BasicUI) Output

func (u *BasicUI) Output(template *Template, data interface{}) error

Output is called for normal standard output.

type Template

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

Template represents a view that will be rendered by the UI.

func NewTemplate

func NewTemplate(t string, options ...TemplateOption) *Template

NewTemplate creates a template for rendering a view.

func (*Template) Render

func (t *Template) Render(data interface{}) (string, error)

Render renders the template with given data.

func (*Template) Write

func (t *Template) Write(writer io.Writer, data interface{}) error

type TemplateOption

type TemplateOption func(TemplateOptions)

TemplateOption captures a tweak that can be applied to the Template.

func OptionColor

func OptionColor(i bool) TemplateOption

OptionColor allows the setting a color option to configure the template.

func OptionFormat

func OptionFormat(i string) TemplateOption

OptionFormat allows the setting a format option to configure the template.

func OptionFunctions

func OptionFunctions(i map[string]interface{}) TemplateOption

OptionFunctions allows the setting a functions option to configure the template.

func OptionName

func OptionName(i string) TemplateOption

OptionName allows the setting a name option to configure the template.

type TemplateOptions

type TemplateOptions interface {
	SetName(string)
	SetFormat(string)
	SetColor(bool)
	SetFunctions(map[string]interface{})
}

TemplateOptions represents a way to set optional values to a template option. The TemplateOptions shows what options are available to change.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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