Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// HelpInputRune is the rune which the user should enter to trigger
	// more detailed question help
	HelpInputRune = '?'

	// ErrorIcon will be be shown before an error
	ErrorIcon = "X"

	// HelpIcon will be shown before more detailed question help
	HelpIcon = "?"
	// QuestionIcon will be shown before a question Message
	QuestionIcon = "?"

	// MarkedOptionIcon will be prepended before a selected multiselect option
	MarkedOptionIcon = "[x]"
	// UnmarkedOptionIcon will be prepended before an unselected multiselect option
	UnmarkedOptionIcon = "[ ]"

	// SelectFocusIcon is prepended to an option to signify the user is
	// currently focusing that option
	SelectFocusIcon = ">"
)
View Source
var DisableColor = false
View Source
var ErrorTemplate = `{{color "red"}}{{ ErrorIcon }} Sorry, your reply was invalid: {{.Error}}{{color "reset"}}
`
View Source
var TemplateFuncs = map[string]interface{}{

	"color": func(color string) string {
		if DisableColor {
			return ""
		}
		return ansi.ColorCode(color)
	},
	"HelpInputRune": func() string {
		return string(HelpInputRune)
	},
	"ErrorIcon": func() string {
		return ErrorIcon
	},
	"HelpIcon": func() string {
		return HelpIcon
	},
	"QuestionIcon": func() string {
		return QuestionIcon
	},
	"MarkedOptionIcon": func() string {
		return MarkedOptionIcon
	},
	"UnmarkedOptionIcon": func() string {
		return UnmarkedOptionIcon
	},
	"SelectFocusIcon": func() string {
		return SelectFocusIcon
	},
}

Functions

func RunTemplate

func RunTemplate(tmpl string, data interface{}) (string, error)

func SetFancyIcons

func SetFancyIcons()

    SetFancyIcons changes the err, help, marked, and focus input icons to their fancier forms. These forms may not be compatible with most terminals. This function will not touch the QuestionIcon as its fancy and non fancy form are the same.

    func WriteAnswer

    func WriteAnswer(t interface{}, name string, v interface{}) (err error)

    Types

    type Renderer

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

    func (*Renderer) Error

    func (r *Renderer) Error(invalid error) error

    func (*Renderer) NewCursor

    func (r *Renderer) NewCursor() *terminal.Cursor

    func (*Renderer) NewRuneReader

    func (r *Renderer) NewRuneReader() *terminal.RuneReader

    func (*Renderer) Render

    func (r *Renderer) Render(tmpl string, data interface{}) error

    func (*Renderer) Stdio

    func (r *Renderer) Stdio() terminal.Stdio

    func (*Renderer) WithStdio

    func (r *Renderer) WithStdio(stdio terminal.Stdio)

    Notes

    Bugs

      • the current implementation might cause weird conflicts if there are two fields with same name that only differ by casing.