Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrGracefulExit = fmt.Errorf("graceful exit")
Functions ¶
func AskSecret ¶
AskSecret prompts user to enter a secret, writes prompt to output as an anchor and separates it with a colon
func AskText ¶
AskText prompts user to enter a text, writes prompt to output as an anchor and separates it with a colon
func ListenAndServe ¶
ListenAndServe reads commands from input and calls handler for each command. If handler returns ErrGracefulExit, ListenAndServe stops without error message; If handler returns err != nil, ListenAndServe stops and print error message; If handler returns nil, ListenAndServe continues to read commands.
Types ¶
type Command ¶
type Command struct { // Name first word of given command line Name string // Args arguments of written command, separated by spaces Args []string }
Command info about entered command
func ReadCommand ¶
ReadCommand prompts user to enter a command to input, writes command anchor to output
Example ¶
ListenAndServe(func(cmd *Command) error { if cmd.Name == "exit" { return ErrGracefulExit } fmt.Printf("Command: %s\n", cmd.Name) fmt.Printf("Arguments: %v\n", cmd.Args) return nil })
Output:
Click to show internal directories.
Click to hide internal directories.