Documentation ¶
Index ¶
- Variables
- func InputNumber(prompt string, zero bool) (uint64, error)
- func InputPassword(isConfirm bool, minLen int) (string, error)
- func InputRealNumber(prompt string, p bool) (string, error)
- func InputStartNumber(prompt string, zero bool) (uint64, error)
- func InputText(prompt string, required bool) (string, error)
- type UserPrompter
- type WordCompleter
Constants ¶
This section is empty.
Variables ¶
var Stdin = newTerminalPrompter()
Stdin holds the stdin line reader (also using stdout for printing prompts). Only this reader may be used for input because it keeps an internal buffer.
Functions ¶
func InputPassword ¶
PasswordPrompt 提示输入密码 @param 是否二次确认
func InputRealNumber ¶
InputRealNumber 输入实数值 @param p 是否正数
func InputStartNumber ¶
InputStartNumber 输入数值
Types ¶
type UserPrompter ¶
type UserPrompter interface { // PromptInput displays the given prompt to the user and requests some textual // data to be entered, returning the input of the user. PromptInput(prompt string) (string, error) // PromptPassword displays the given prompt to the user and requests some textual // data to be entered, but one which must not be echoed out into the terminal. // The method returns the input provided by the user. PromptPassword(prompt string) (string, error) // PromptConfirm displays the given prompt to the user and requests a boolean // choice to be made, returning that choice. PromptConfirm(prompt string) (bool, error) // SetHistory sets the the input scrollback history that the prompter will allow // the user to scroll back to. SetHistory(history []string) // AppendHistory appends an entry to the scrollback history. It should be called // if and only if the prompt to append was a valid command. AppendHistory(command string) // ClearHistory clears the entire history ClearHistory() // SetWordCompleter sets the completion function that the prompter will call to // fetch completion candidates when the user presses tab. SetWordCompleter(completer WordCompleter) }
UserPrompter defines the methods needed by the console to promt the user for various types of inputs.
type WordCompleter ¶
WordCompleter takes the currently edited line with the cursor position and returns the completion candidates for the partial word to be completed. If the line is "Hello, wo!!!" and the cursor is before the first '!', ("Hello, wo!!!", 9) is passed to the completer which may returns ("Hello, ", {"world", "Word"}, "!!!") to have "Hello, world!!!".