prompt

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsValidPromptType

func IsValidPromptType(promptType string) bool

IsValidPromptType checks that the given promptType is valid.

Types

type Answer

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

Answers 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 Prompt

type Prompt struct {
	Name      string     `yaml:"name"`
	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"`
}

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) 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.

func (Question) Validator

func (question Question) Validator() survey.Validator

Validator returns the survey.Validator 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.

Jump to

Keyboard shortcuts

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