prompt

package
v0.0.0-...-4c851a9 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package prompt provides interactive terminal prompts for CLI operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ProgressBar

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

ProgressBar displays a simple progress bar.

func NewProgressBar

func NewProgressBar(out io.Writer, total int) *ProgressBar

NewProgressBar creates a new progress bar.

func (*ProgressBar) Complete

func (pb *ProgressBar) Complete()

Complete marks the progress bar as complete.

func (*ProgressBar) Increment

func (pb *ProgressBar) Increment()

Increment increments the progress bar by 1.

func (*ProgressBar) Update

func (pb *ProgressBar) Update(current int)

Update updates the progress bar.

type Prompter

type Prompter struct {
	// In is the input reader (defaults to os.Stdin).
	In io.Reader

	// Out is the output writer (defaults to os.Stderr).
	Out io.Writer

	// Err is the error writer (defaults to os.Stderr).
	Err io.Writer

	// NoColor disables color output.
	NoColor bool

	// NonInteractive skips prompts and uses defaults.
	NonInteractive bool
}

Prompter handles interactive terminal prompts.

func New

func New() *Prompter

New creates a new Prompter with default settings.

func (*Prompter) Confirm

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

Confirm prompts for a yes/no confirmation.

func (*Prompter) Error

func (p *Prompter) Error(message string)

Error prints an error message.

func (*Prompter) Info

func (p *Prompter) Info(message string)

Info prints an info message.

func (*Prompter) Input

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

Input prompts for text input.

func (*Prompter) IsInteractive

func (p *Prompter) IsInteractive() bool

IsInteractive returns true if the terminal is interactive.

func (*Prompter) MultiSelect

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

MultiSelect prompts the user to select multiple options.

func (*Prompter) Password

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

Password prompts for a password (hidden input).

func (*Prompter) Print

func (p *Prompter) Print(format string, args ...interface{})

Print outputs colored text if color is enabled.

func (*Prompter) Select

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

Select prompts the user to select from a list of options.

func (*Prompter) Success

func (p *Prompter) Success(message string)

Success prints a success message.

func (*Prompter) Warning

func (p *Prompter) Warning(message string)

Warning prints a warning message.

type Spinner

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

Spinner displays a simple progress indicator.

func NewSpinner

func NewSpinner(out io.Writer, message string) *Spinner

NewSpinner creates a new spinner with a message.

type Table

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

Table renders a simple table.

func NewTable

func NewTable(out io.Writer, headers ...string) *Table

NewTable creates a new table.

func (*Table) AddRow

func (t *Table) AddRow(values ...string)

AddRow adds a row to the table.

func (*Table) Render

func (t *Table) Render()

Render renders the table to output.

Jump to

Keyboard shortcuts

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