prompt

package
v0.6.3 Latest Latest
Warning

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

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

Documentation

Overview

Package prompt provides utilities for interactive user prompts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Prompter

type Prompter struct {
	// contains filtered or unexported fields
}

Prompter handles interactive user prompts.

func New

func New(in io.Reader, out io.Writer) *Prompter

New creates a new Prompter that reads from in and writes to out.

func (*Prompter) Confirm

func (p *Prompter) Confirm(message string) (bool, error)

Confirm prompts the user with a yes/no question. Returns true if the user answers yes, false otherwise. The default behavior is to return false (no) if the user just presses enter.

func (*Prompter) ConfirmWithDefault

func (p *Prompter) ConfirmWithDefault(message string, defaultYes bool) (bool, error)

ConfirmWithDefault prompts the user with a yes/no question with a specific default. If defaultYes is true, the default is yes (Y/n), otherwise it's no (y/N).

func (*Prompter) Input

func (p *Prompter) Input(message string) (string, error)

Input prompts the user for text input.

func (*Prompter) Select

func (p *Prompter) Select(message string, options []string) (int, error)

Select prompts the user to choose from a list of options. Returns the index of the selected option (0-based) or -1 if invalid/cancelled.

Jump to

Keyboard shortcuts

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