ask

package module
v0.0.0-...-b10b32d Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2016 License: MIT Imports: 5 Imported by: 0

README

Ask

GoDoc Build Status

Very simple package to prompt questions and get answers without having to deal with the data streams.

Installation
go get github.com/rayrutjes/ask

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Ask

func Ask(q string) (string, error)

Ask writes a question to the standard output and reads the answer from the standard input.

func Confirm

func Confirm(question string) (bool, error)

Confirm prompts the user with a yes/no question. Keeps prompting the question until the users answers with "y" or "n". Returns a boolean value indicating if the user confirmed or infirmed. Question and answers are written and read back from standard output/input.

func Fask

func Fask(q string, w io.Writer, r io.Reader) (string, error)

Fask writes the question into to given writer and returns the answer from the reader.

func Fconfirm

func Fconfirm(question string, w io.Writer, r io.Reader) (bool, error)

Fconfirm prompts the user with a yes/no question. Keeps prompting the question until the users answers with "y" or "n". Returns a boolean value indicating if the user confirmed or infirmed.

func Fwhile

func Fwhile(q string, v ValidateFunc, w io.Writer, r io.Reader) (string, error)

Fwhile writes a question and returns the answer once the validation function returns true. The questions is written again on each failed validation pass.

func While

func While(q string, v ValidateFunc) (string, error)

While writes a question and returns the answer once the validation function returns true. The questions is written again on each failed validation pass.

Types

type ValidateFunc

type ValidateFunc func(string) (bool, string)

ValidateFunc is a function that is used to validate that an answer matches the expectations. It should return a boolean and an additional validation failure message when the validation fails.

Jump to

Keyboard shortcuts

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