Documentation ¶
Overview ¶
Package interact provides helper methods for interacting with the CLI user at command run time.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindMatch ¶
FindMatch does a case-insensitive search of the given options and returns the matching option. Found reports whether s was found in the options.
func MatchOptions ¶
MatchOptions returns a function that performs a case insensitive comparison against the given list of options. To make a verification function that accepts an empty default, include an empty string in the list.
func QueryVerify ¶
func QueryVerify(question []byte, scanner *bufio.Scanner, w io.Writer, verify func(string) error) (answer string, err error)
QueryVerify writes a question to w and waits for an answer to be read from scanner. It will pass the answer into the verify function. Verify, if non-nil, should check the answer for validity, returning an error that will be written out to the user, or nil if answer is valid.
This function takes a scanner rather than an io.Reader to avoid the case where the scanner reads past the delimiter and thus might lose data. It is expected that this method will be used repeatedly with the same scanner if multiple queries are required.
Types ¶
This section is empty.