io

package
v3.20.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: MIT Imports: 15 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 Pager added in v3.17.0

func Pager(noPager bool) (w io.Writer, cleanup func() error)

Pager returns a writer hooked up to a pager (default: less -R) when stdout is a TTY. Falls back to stdout when paging is disabled or the pager cannot run.

func ProgressBar added in v3.17.0

func ProgressBar(completed, total, width int) string

func ProgressLine added in v3.17.0

func ProgressLine(label string, completed, total, succeeded, failed, barWidth int) string

func PromptForInput added in v3.17.0

func PromptForInput(prompt, defaultVal string, noInput bool) (string, error)

PromptForInput prompts the user to enter a string value. If a default value is provided, it will be shown in brackets and used if the user presses enter. If noInput is true, it will return the default value or an error if no default is provided.

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. If there's no TTY available, it will also 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(f *factory.Factory, 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