input

package
v0.0.0-...-51958b5 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const LineSep = "\n"

LineSep is the separator for windows or unix systems

Variables

View Source
var (
	// Errs are error returned by input functions.
	// It's useful for handling error from outside of input functions.
	ErrEmpty       = errors.New("default value is not provided but input is empty")
	ErrNotNumber   = errors.New("input must be number")
	ErrOutOfRange  = errors.New("input is out of range")
	ErrInterrupted = errors.New("interrupted")
)

Functions

func Continue

func Continue()

Types

type Options

type Options struct {
	Key      string
	Options  []string
	Default  string
	Loop     bool
	Required bool
	// contains filtered or unexported fields
}

type Query

type Query struct {
	Q    string
	Opts *Options
}

type UI

type UI struct {
	Queries []*Query
	Writer  io.Writer
	Reader  io.Reader
	// contains filtered or unexported fields
}

func DefaultUI

func DefaultUI() *UI

DefaultUI returns default UI. It outputs to stdout and intputs from stdin.

func (*UI) AddQueries

func (u *UI) AddQueries(q ...*Query)

func (*UI) Ask

func (i *UI) Ask(q *Query) (string, error)

func (*UI) AskStringVar

func (i *UI) AskStringVar(q *Query, v *string) error

func (*UI) Enquire

func (u *UI) Enquire()

func (*UI) Select

func (i *UI) Select(q *Query) (string, error)

func (*UI) SingleQuery

func (u *UI) SingleQuery(q string, opts *Options) *Query

type ValidateFunc

type ValidateFunc func(string) error

Jump to

Keyboard shortcuts

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