Documentation
¶
Index ¶
- func Plain(s string) string
- func ScanLine() string
- func Secret(s string) string
- func Strict(s, pattern string) string
- func StrictSecret(s, pattern string) string
- func Until(s string) string
- func UntilSecret(s string) string
- func UntilStrict(s, pattern string) string
- func UntilStrictSecret(s, pattern string) string
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Plain ¶
Plain simply prompts the user to enter text interactively.
Example ¶
package main import ( "fmt" "github.com/rwxrob/prompt" ) func main() { it := prompt.Plain("Enter something: ") fmt.Println("Got:", it) }
Output:
func ScanLine ¶
func ScanLine() string
ScanLine uses the bufio.NewScanner (which defaults to limited line scanning) to safely scan a reasonably long line of standard input. Note that other methods could introduce dangerous input reads that could consume all available memory. Note this does not check for scanner error conditions returning an empty string instead in such cases.
func Secret ¶
Secret prompts the user to enter text interactively but does not echo what they are typing to the screen. Warning: only works where the syscall.Stdin is supported.
Example ¶
package main import ( "fmt" "github.com/rwxrob/prompt" ) func main() { it := prompt.Secret("Enter secret (you won't see): ") fmt.Println("Got:", it) }
Output:
func Strict ¶
Strict prompts the user to enter text interactively that must strictly match the regular expression provided.
Example ¶
package main import ( "fmt" "github.com/rwxrob/prompt" ) func main() { it := prompt.Strict("Enter a number: ", "[0-9]") fmt.Println("Got:", it) }
Output:
func StrictSecret ¶
StrictSecret prompts the user to enter text interactively that must strictly match the regular expression provided but without echoing the input to the terminal.
func Until ¶
Until is identical to Plain but loops until at least one non-whitespace character is entered, which is simply a convenient way of writing UntilStrict("some","\\S").
func UntilSecret ¶
UntilSecret is identical to Secret but loops until at least one non-whitespace character is entered, which is simply a convenient way of writing UntilStrictSecret("some","\\S").
func UntilStrict ¶
UntilStrict prompts continuously until the user response matches. Note that if the pattern cannot be matched that this function will never return.
func UntilStrictSecret ¶
UntilStrictSecret is identical to StrictSecret but prompts until the input matches the given pattern.
Types ¶
This section is empty.