core

package
v2.0.8-0...-fc4e006 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DisableColor = false

DisableColor can be used to make testing reliable

View Source
var TemplateFuncs = map[string]interface{}{

	"color": func(color string) string {
		if DisableColor {
			return ""
		}
		return ansi.ColorCode(color)
	},
}

Functions

func IsFieldNotMatch

func IsFieldNotMatch(err error) (string, bool)

IsFieldNotMatch reports whether an "err" is caused by a non matching field. It returns the Question.Name that couldn't be matched with a destination field.

Usage: err := survey.Ask(qs, &v);

if err != nil {
	if name, ok := core.IsFieldNotMatch(err); ok {
		[...name is the not matched question name]
	}
}

func RunTemplate

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

func WriteAnswer

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

Types

type OptionAnswer

type OptionAnswer struct {
	Value string
	Index int
}

OptionAnswer is the return type of Selects/MultiSelects that lets the appropriate information get copied to the user's struct

func OptionAnswerList

func OptionAnswerList(incoming []string) []OptionAnswer

type Settable

type Settable interface {
	WriteAnswer(field string, value interface{}) error
}

Settable allow for configuration when assigning answers

Notes

Bugs

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

Jump to

Keyboard shortcuts

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