comms

package
v3.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Question

type Question struct {
	Reader       io.Reader
	Writer       io.Writer
	Prompt       string
	DefaultValue string
}

Question provides an interactive session.

func (*Question) Ask

func (q *Question) Ask() (string, error)

Ask displays the prompt, then records the response.

func (Question) Read

func (q Question) Read(r io.Reader) (string, error)

Read reads the user's input.

type Selection

type Selection struct {
	Items  []fmt.Stringer
	Reader io.Reader
	Writer io.Writer
}

Selection wraps a list of items. It is used for interactive communication.

func NewSelection

func NewSelection() Selection

NewSelection prepares an empty collection for interactive input.

func (Selection) Display

func (sel Selection) Display() string

Display shows a numbered list of the solutions to choose from. The list starts at 1, since that seems better in a user interface.

func (Selection) Get

func (sel Selection) Get(n int) (fmt.Stringer, error)

Get returns the solution corresponding to the number. The list starts at 1, since that seems better in a user interface.

func (Selection) Pick

func (sel Selection) Pick(prompt string) (fmt.Stringer, error)

Pick lets a user interactively select an option from a list.

func (Selection) Read

func (sel Selection) Read(r io.Reader) (int, error)

Read reads the user's selection and converts it to a number.

Jump to

Keyboard shortcuts

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