prompt

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2016 License: BSD-3-Clause Imports: 1 Imported by: 0

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 {
	Choosen bool   // Set to true if choosen.
	Value   string // Value used if choosen 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