Documentation
¶
Index ¶
- func Confirm(f *factory.Factory, prompt string) (bool, error)
- func HasDataAvailable(reader io.Reader) bool
- func PromptForOne(resource string, options []string, noInput bool) (string, error)
- func ReadLine() (string, error)
- func ReadPassword() (string, error)
- func SpinWhile(name string, action func()) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Confirm ¶
Confirm prompts the user with a yes/no question. Returns true if the user confirmed, false otherwise.
IMPORTANT: Commands using Confirm() must call f.SetGlobalFlags(cmd) in PreRunE. See factory.SetGlobalFlags() documentation for details.
Usage:
confirmed, err := io.Confirm(f, "Do the thing?")
if err != nil {
return err
}
if confirmed {
// do the thing
}
func HasDataAvailable ¶
HasDataAvailable will return whether the given Reader has data available to read
func PromptForOne ¶
PromptForOne will show the list of options to the user, allowing them to select one to return. It's possible for them to choose none or cancel the selection, resulting in an error. If noInput is true, it will fail instead of prompting.
For global flag support requirements, see the Confirm() function documentation.
func ReadLine ¶ added in v3.14.2
ReadLine reads a line of input from stdin with terminal support. If running in a TTY, it uses x/term for better line editing (backspace, arrows, etc.). If not in a TTY (e.g., piped input), it falls back to bufio.
func ReadPassword ¶ added in v3.14.2
ReadPassword reads a password from stdin without echoing. This is a convenience wrapper around term.ReadPassword.
Types ¶
This section is empty.