package prompt
import "github.com/docker/cli/internal/prompt"
Index ¶
- Constants
- func Confirm(ctx context.Context, in io.Reader, out io.Writer, message string) (bool, error)
- func DisableInputEcho(ins *streams.In) (restore func() error, _ error)
- func ReadInput(ctx context.Context, in io.Reader, out io.Writer, message string) (string, error)
Constants ¶
const ErrTerminated cancelledErr = "prompt terminated"
Functions ¶
func Confirm ¶
Confirm requests and checks confirmation from the user.
It displays the provided message followed by "y/N". If the user input 'y' or 'Y' it returns true otherwise false. If no message is provided, "Are you sure you want to proceed? y/N " will be used instead.
It returns false with an ErrTerminated if the user terminates the CLI with SIGINT or SIGTERM while the prompt is active. If the prompt returns an error, the caller should close the io.Reader used for the prompt and propagate the error up the stack to prevent the background goroutine from blocking indefinitely.
func DisableInputEcho ¶
DisableInputEcho disables input echo on the provided streams.In. This is useful when the user provides sensitive information like passwords. The function returns a restore function that should be called to restore the terminal state.
TODO(thaJeztah): implement without depending on streams?
func ReadInput ¶
ReadInput requests input from the user.
It returns an empty string ("") with an ErrTerminated if the user terminates the CLI with SIGINT or SIGTERM while the prompt is active. If the prompt returns an error, the caller should close the io.Reader used for the prompt and propagate the error up the stack to prevent the background goroutine from blocking indefinitely.
Source Files ¶
- Version
- v28.1.1+incompatible (latest)
- Published
- Apr 18, 2025
- Platform
- linux/amd64
- Imports
- 8 packages
- Last checked
- 4 hours ago –
Tools for package owners.