prompt

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Answers = make(GlobalAnswers)

Answers are the global stored answers

Functions

func IsValidPromptType

func IsValidPromptType(promptType string) bool

IsValidPromptType checks that the given promptType is valid.

func IsValidTransformerType added in v1.7.0

func IsValidTransformerType(transformerType string) bool

IsValidTransformerType checks that the given promptType is valid.

func IsValidValidatorType added in v1.7.0

func IsValidValidatorType(validatorType string) bool

IsValidValidatorType checks that the given promptType is valid.

Types

type Answer

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

Answer holds the Prompt Answer configuration.

func (*Answer) WriteAnswer

func (answer *Answer) WriteAnswer(name string, value interface{}) error

WriteAnswer writes the answers to the global AnswerMap var.

type AnswerMap

type AnswerMap map[string]interface{}

AnswerMap is the answers map type

type GlobalAnswers added in v1.7.0

type GlobalAnswers map[string]AnswerMap

GlobalAnswers is all prompt answers.

type Prompt

type Prompt struct {
	Name      string `yaml:"name"`
	Answers   AnswerMap
	Questions []Question `yaml:"questions"`
}

Prompt holds Prompt configuration.

func Make

func Make(name string, questions []Question) Prompt

Make creates a Prompt and returns it.

func (Prompt) Ask

func (p Prompt) Ask() AnswerMap

Ask initializes the survey prompt, asking the questions provided.

type Question

type Question struct {
	Name      string             `yaml:"name"`
	Type      string             `yaml:"type"`
	Options   QuestionOptions    `yaml:"prompt"`
	Validate  QuestionValidation `yaml:"validate"`
	Transform string             `yaml:"transform"`
	When      string             `yaml:"when"`
}

Question holds the Survey question configs.

func (Question) AsSurveyQuestion

func (question Question) AsSurveyQuestion() survey.Question

AsSurveyQuestion coerces the question into a survey.Question type.

func (Question) CheckValid added in v1.7.0

func (question Question) CheckValid(ans interface{}) error

CheckValid checks if the question's answer is valid according to the specifications for the specified Question.

func (Question) Prompt

func (question Question) Prompt() survey.Prompt

Prompt constructs a new survey.Prompt instance from the Question.

func (Question) Transformer

func (question Question) Transformer() survey.Transformer

Transformer returns the survey.Transformer for the specific Question.

type QuestionOptions

type QuestionOptions struct {
	Message       string   `yaml:"message"`
	Default       string   `yaml:"default"`
	Help          string   `yaml:"help"`
	Options       []string `yaml:"options"`
	PageSize      int      `yaml:"pageSize"`
	VimMode       bool     `yaml:"vimMode"`
	Editor        string   `yaml:"editor"`
	HideDefault   bool     `yaml:"hideDefault"`
	AppendDefault bool     `yaml:"appendDefault"`
	FileName      string   `yaml:"fileName"`
}

QuestionOptions provides option storage for Survey Question instances.

type QuestionValidation

type QuestionValidation struct {
	Required  bool `yaml:"required"`
	MinLength int  `yaml:"minLength"`
	MaxLength int  `yaml:"maxLength"`
}

QuestionValidation provides validation options for Survey Question instances.

type WhenEnvironment added in v1.7.0

type WhenEnvironment struct {
	Answers AnswerMap
	Env     map[string]string
}

WhenEnvironment is the object passed into the When environment.

Jump to

Keyboard shortcuts

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