io

package
v3.14.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Confirm

func Confirm(f *factory.Factory, prompt string) (bool, error)

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

func HasDataAvailable(reader io.Reader) bool

HasDataAvailable will return whether the given Reader has data available to read

func PromptForOne

func PromptForOne(resource string, options []string, noInput bool) (string, error)

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

func ReadLine() (string, error)

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

func ReadPassword() (string, error)

ReadPassword reads a password from stdin without echoing. This is a convenience wrapper around term.ReadPassword.

func SpinWhile added in v3.4.1

func SpinWhile(name string, action func()) error

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL