prompt

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2017 License: BSD-3-Clause Imports: 1 Imported by: 108

Documentation

Overview

Package prompt prompts user for feedback.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option struct {
	Chosen bool   // Set to true if chosen.
	Value  string // Value used if chosen and option is "other".
	// contains filtered or unexported fields
}

func NewOption

func NewOption(key interface{}, prompt string, other bool) Option

func ValidateOption

func ValidateOption(opt Option, validation string) Option

func (Option) Key

func (opt Option) Key() interface{}

func (Option) Other

func (opt Option) Other() bool

func (Option) Prompt

func (opt Option) Prompt() string

func (Option) String

func (opt Option) String() string

func (Option) Validation

func (opt Option) Validation() string

type OptionType

type OptionType byte
const (
	TypeSelectOne      OptionType = iota // Allow user to choose single option.
	TypeSelectMultiple                   // Allow user to choose multiple options.
)

type Prompt

type Prompt interface {
	Ask(q *Question) (Response, error)
}

type Question

type Question struct {
	Error   string
	Prompt  string
	Type    OptionType
	Options []Option
}

func (*Question) AnswerMultiple

func (q *Question) AnswerMultiple(must bool) []*Option

func (*Question) AnswerSingle

func (q *Question) AnswerSingle(must bool) *Option

type Response

type Response byte
const (
	RespAnswer Response = iota
	RespCancel
)

Jump to

Keyboard shortcuts

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