tap

package module
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 18 Imported by: 4

README

Tap

CI

A Go library for building beautiful, interactive command-line prompts and terminal UI components.

Features

  • Interactive Prompts: Text input, password, confirmation, single/multi-select, autocomplete, and multiline textarea
  • Progress Indicators: Spinners with customizable frames and progress bars with multiple styles
  • Output Utilities: Styled tables, boxed messages, and streaming output
  • Modern API: Context-aware, generic types for select options, functional options pattern
  • Cross-Platform: Unix and Windows terminal support
  • Multiline Input: Textarea supports multiline editing with Shift+Enter for new lines and Up/Down navigation

Installation

go get github.com/yarlson/tap

Requirements: Go 1.24+

Quick Start

Text Input
package main

import (
    "context"
    "fmt"

    "github.com/yarlson/tap"
)

func main() {
    name := tap.Text(context.Background(), tap.TextOptions{
        Message:     "Enter your name:",
        Placeholder: "Type something...",
    })
    fmt.Printf("Hello, %s!\n", name)
}
Select Menu
colors := []tap.SelectOption[string]{
    {Value: "red", Label: "Red", Hint: "The color of passion"},
    {Value: "blue", Label: "Blue", Hint: "The color of calm"},
    {Value: "green", Label: "Green", Hint: "The color of nature"},
}

result := tap.Select[string](context.Background(), tap.SelectOptions[string]{
    Message: "What's your favorite color?",
    Options: colors,
})
fmt.Printf("You selected: %s\n", result)
Spinner
spin := tap.NewSpinner(tap.SpinnerOptions{})
spin.Start("Connecting")
// ... do work ...
spin.Stop("Connected", 0)

// With hint (optional second line in gray)
spin.Stop("Installed 42 packages", 0, tap.StopOptions{
    Hint: "Run 'npm start' to begin",
})
Progress Bar
progress := tap.NewProgress(tap.ProgressOptions{
    Style: "heavy",
    Max:   100,
    Size:  40,
})

progress.Start("Downloading...")
for i := 0; i <= 100; i += 10 {
    progress.Advance(10, fmt.Sprintf("Downloading... %d%%", i))
}
progress.Stop("Download complete!", 0)

// With hint (optional second line in gray)
progress.Stop("Download complete!", 0, tap.StopOptions{
    Hint: "Saved to ~/Downloads/file.zip (128 MB)",
})
Textarea
res := tap.Textarea(context.Background(), tap.TextareaOptions{
    Message:     "Enter your commit message:",
    Placeholder: "Type something...",
    Validate: func(s string) error {
        if len(s) < 10 {
            return fmt.Errorf("at least 10 characters required")
        }
        return nil
    },
})
fmt.Println(res)

Use Shift+Enter to insert new lines. Pasted content is collapsed into [Text N] placeholders and expanded on submit.

Messages with Hints
// Message, Outro, and Cancel support optional hints
tap.Message("Task completed", tap.MessageOptions{
    Hint: "Processed 42 items in 1.2s",
})

tap.Outro("All done!", tap.MessageOptions{
    Hint: "Run 'app --help' for more options",
})

Keyboard Shortcuts

All Prompts
Key Action
Return (Enter) Submit/confirm selection
Escape or ^C Cancel and exit prompt
Left/Right Move cursor left/right
Backspace/Del Delete character
Textarea
Key Action
Shift+Return Insert new line (multiline input)
Up/Down Move to previous/next line
Home Move to start of current line
End Move to end of current line
Return Submit multiline text

API Reference

Interactive Prompts
Function Description Return Type
Text(ctx, TextOptions) Single-line text input string
Password(ctx, PasswordOptions) Masked password input string
Confirm(ctx, ConfirmOptions) Yes/No confirmation bool
Select[T](ctx, SelectOptions[T]) Single-choice selection T
MultiSelect[T](ctx, MultiSelectOptions[T]) Multiple-choice selection []T
Textarea(ctx, TextareaOptions) Multiline text input string
Autocomplete(ctx, AutocompleteOptions) Text input with suggestions string
Progress Components
Function Description
NewSpinner(SpinnerOptions) Animated spinner indicator
NewProgress(ProgressOptions) Progress bar with percentage
NewStream(StreamOptions) Streaming output with optional timer
Output Utilities
Function Description
Table(headers, rows, TableOptions) Render formatted tables
Box(message, title, BoxOptions) Render boxed messages
Intro(title, ...MessageOptions) Display intro message
Outro(message, ...MessageOptions) Display outro message
Message(message, ...MessageOptions) Display styled message
Options Structs
TextOptions
type TextOptions struct {
    Message      string
    Placeholder  string
    DefaultValue string
    InitialValue string
    Validate     func(string) error
    Input        Reader
    Output       Writer
}
TextareaOptions
type TextareaOptions struct {
    Message      string             // Prompt label displayed above the input area
    Placeholder  string             // Hint text shown when input is empty
    DefaultValue string             // Value returned when user submits empty input
    InitialValue string             // Pre-populated editable content on prompt start
    Validate     func(string) error // Validates the fully-resolved string on submit
    Input        Reader
    Output       Writer
}

Validate receives the resolved string with all paste placeholders expanded. Return an error to reject the input — the error message is displayed below the input and the user can continue editing.

SelectOptions
type SelectOptions[T any] struct {
    Message      string
    Options      []SelectOption[T]
    InitialValue *T
    MaxItems     *int
    Input        Reader
    Output       Writer
}
SpinnerOptions
type SpinnerOptions struct {
    Indicator string        // "dots" (default) or "timer"
    Frames    []string      // custom animation frames
    Delay     time.Duration // frame delay
}
ProgressOptions
type ProgressOptions struct {
    Style string  // "heavy", "light", or "block"
    Max   int     // maximum value
    Size  int     // bar width in characters
}
TableOptions
type TableOptions struct {
    ShowBorders      bool
    IncludePrefix    bool
    MaxWidth         int
    ColumnAlignments []TableAlignment
    HeaderStyle      TableStyle
    HeaderColor      TableColor
    FormatBorder     func(string) string
}
MessageOptions
type MessageOptions struct {
    Output Writer
    Hint   string // Optional second line displayed in gray
}
StopOptions

Used with Spinner.Stop() and Progress.Stop() to add an optional hint line:

type StopOptions struct {
    Hint string // Optional second line displayed in gray below the message
}

Examples

Run interactive examples:

go run ./examples/text/main.go
go run ./examples/textarea/main.go
go run ./examples/password/main.go
go run ./examples/select/main.go
go run ./examples/multiselect/main.go
go run ./examples/confirm/main.go
go run ./examples/autocomplete/main.go
go run ./examples/spinner/main.go
go run ./examples/progress/main.go
go run ./examples/messages/main.go
go run ./examples/table/main.go
go run ./examples/stream/main.go

Compatibility

Platform Support

Terminal signal handling differs between Unix and Windows. The library includes platform-specific implementations:

  • internal/terminal/terminal_unix.go - Unix signal handling
  • internal/terminal/terminal_windows.go - Windows signal handling
Textarea Terminal Requirements

Shift+Enter (multiline input) requires a terminal that reports modifier keys. Supported terminals include iTerm2, kitty, Alacritty, WezTerm, Ghostty, and Windows Terminal. Terminals that don't distinguish Shift+Enter from Enter (e.g., macOS Terminal.app) cannot insert newlines via keyboard — users can paste multiline content instead.

Bracketed paste mode enables paste detection and [Text N] placeholder collapsing. Supported by all major modern terminals. Terminals without bracketed paste support degrade to character-by-character input — functional but without placeholder collapsing.

Environment Variables
Variable Required Description
TERM No Terminal type for ANSI escape sequence support

Development

Running Tests
go test ./...

With race detection:

go test -race ./...
Linting

The project uses golangci-lint with configuration in .golangci.yml:

golangci-lint run
Testing Patterns

Override terminal I/O for deterministic tests:

in := tap.NewMockReadable()
out := tap.NewMockWritable()
tap.SetTermIO(in, out)
defer tap.SetTermIO(nil, nil)

// Simulate keypresses
go func() {
    in.EmitKeypress("h", tap.Key{Name: "h"})
    in.EmitKeypress("i", tap.Key{Name: "i"})
    in.EmitKeypress("", tap.Key{Name: "return"})
}()

result := tap.Text(ctx, tap.TextOptions{Message: "Enter:"})

Troubleshooting

Platform-specific signal handling

Symptom: Terminal signal handling differs between Unix and Windows

Solution: The library includes platform-specific implementations. Ensure you're building for the correct target platform. Check internal/terminal/terminal_unix.go and internal/terminal/terminal_windows.go for platform-specific behavior.

ANSI sequence handling for width calculations

Symptom: Text width calculations may produce unexpected results with styled text

Solution: The library handles ANSI escape sequences in width calculations via visibleWidth() and truncateToWidth() functions in ansi_utils.go. Ensure styled text is properly formatted with reset sequences.

Contributing

Contributions are welcome. When contributing:

  • Follow existing code patterns and naming conventions
  • Add unit tests using the mock I/O pattern
  • Add examples under examples/<feature>/main.go for new features
  • Run go test ./... and golangci-lint run before submitting

License

MIT License - see LICENSE for details.

Documentation

Index

Constants

View Source
const (
	// Step symbols.
	StepActive = "◆"
	StepCancel = "■"
	StepError  = "▲"
	StepSubmit = "◇"

	// Bar symbols.
	Bar           = "│"
	BarH          = "─"
	BarStart      = "┌"
	BarStartRight = "┐"
	BarEnd        = "└"
	BarEndRight   = "┘"

	// Corner symbols (rounded).
	CornerTopLeft     = "╭"
	CornerTopRight    = "╮"
	CornerBottomLeft  = "╰"
	CornerBottomRight = "╯"

	// Radio symbols.
	RadioActive   = "●"
	RadioInactive = "○"

	// Checkbox symbols for multiselect.
	CheckboxChecked   = "◼"
	CheckboxUnchecked = "◻"
)

Unicode symbols for drawing styled prompts.

View Source
const (
	Reset = "\033[0m"

	// Colors.
	Gray   = "\033[90m"
	Red    = "\033[91m"
	Green  = "\033[92m"
	Yellow = "\033[93m"
	Cyan   = "\033[96m"

	// Text styles.
	Dim           = "\033[2m"
	Bold          = "\033[1m"
	Inverse       = "\033[7m"
	Strikethrough = "\033[9m"
)

ANSI color codes.

View Source
const (
	// Table border symbols.
	TableTopLeft     = "┌"
	TableTopRight    = "┐"
	TableBottomLeft  = "└"
	TableBottomRight = "┘"
	TableTopTee      = "┬"
	TableBottomTee   = "┴"
	TableLeftTee     = "├"
	TableRightTee    = "┤"
	TableCross       = "┼"
	TableHorizontal  = "─"
	TableVertical    = "│"
)

Table symbols.

View Source
const (
	CursorHide = terminal.CursorHide
	CursorShow = terminal.CursorShow
	EraseLine  = terminal.ClearLine
	CursorUp   = terminal.CursorUp
	EraseDown  = terminal.EraseDown
)

Variables

This section is empty.

Functions

func Autocomplete added in v0.10.0

func Autocomplete(ctx context.Context, opts AutocompleteOptions) string

Autocomplete renders a text prompt with inline suggestions.

func Box

func Box(message, title string, opts BoxOptions)

Box renders a framed message with optional title.

func Cancel

func Cancel(message string, opts ...MessageOptions)

Cancel prints a cancel-styled message (bar end + red message).

func Confirm

func Confirm(ctx context.Context, opts ConfirmOptions) bool

Confirm creates a styled confirm prompt.

func CyanBorder

func CyanBorder(s string) string

func GrayBorder

func GrayBorder(s string) string

func GreenBorder added in v0.10.0

func GreenBorder(s string) string

func Intro

func Intro(title string, opts ...MessageOptions)

Intro prints an intro title (bar start + title).

func Message added in v0.9.0

func Message(message string, opts ...MessageOptions)

func MultiSelect added in v0.5.0

func MultiSelect[T any](ctx context.Context, opts MultiSelectOptions[T]) []T

MultiSelect renders a styled multi-select and returns selected values.

func Outro

func Outro(message string, opts ...MessageOptions)

Outro prints a final outro (bar line, then bar end + message).

func Password

func Password(ctx context.Context, opts PasswordOptions) string

Password creates a styled password input prompt that masks user input.

func RedBorder added in v0.10.0

func RedBorder(s string) string

func Select

func Select[T any](ctx context.Context, opts SelectOptions[T]) T

Select creates a styled select prompt.

func SetTermIO added in v0.4.0

func SetTermIO(in Reader, out Writer)

SetTermIO sets a custom reader and writer used by helpers. Pass nil values to restore default terminal behavior.

func Symbol added in v0.7.0

func Symbol(state ClackState) string

Symbol returns the appropriate symbol for a given state with color.

func Table added in v0.9.0

func Table(headers []string, rows [][]string, opts TableOptions)

Table renders a formatted table with headers and rows.

func Text

func Text(ctx context.Context, opts TextOptions) string

Text creates a styled text input prompt.

func Textarea added in v0.13.0

func Textarea(ctx context.Context, opts TextareaOptions) string

Textarea creates a styled multiline text input prompt.

func YellowBorder added in v0.10.0

func YellowBorder(s string) string

Types

type AutocompleteOptions added in v0.10.0

type AutocompleteOptions struct {
	Message      string
	Placeholder  string
	DefaultValue string
	InitialValue string
	Validate     func(string) error
	Suggest      func(string) []string // returns suggestion list for current input
	MaxResults   int                   // maximum suggestions to show (default 5)
	Input        Reader
	Output       Writer
}

AutocompleteOptions defines options for styled autocomplete text prompt.

type BoxAlignment

type BoxAlignment string
const (
	BoxAlignLeft   BoxAlignment = "left"
	BoxAlignCenter BoxAlignment = "center"
	BoxAlignRight  BoxAlignment = "right"
)

type BoxOptions

type BoxOptions struct {
	Output         Writer
	Columns        int          // terminal columns; if 0, default to 80
	WidthFraction  float64      // 0..1 fraction of Columns; ignored if WidthAuto
	WidthAuto      bool         // compute width to content automatically (capped by Columns)
	TitlePadding   int          // spaces padding inside borders around title
	ContentPadding int          // spaces padding inside borders around content lines
	TitleAlign     BoxAlignment // left|center|right
	ContentAlign   BoxAlignment // left|center|right
	Rounded        bool
	IncludePrefix  bool
	FormatBorder   func(string) string // formatter for border glyphs (e.g., color)
}

type ClackState added in v0.7.0

type ClackState string
const (
	StateInitial ClackState = "initial"
	StateActive  ClackState = "active"
	StateCancel  ClackState = "cancel"
	StateSubmit  ClackState = "submit"
	StateError   ClackState = "error"
)

type ConfirmOptions

type ConfirmOptions struct {
	Message      string
	Active       string
	Inactive     string
	InitialValue bool
	Input        Reader
	Output       Writer
}

ConfirmOptions defines options for styled confirm prompt.

type EventHandler added in v0.7.0

type EventHandler any

type Key added in v0.7.0

type Key = terminal.Key

type MessageOptions added in v0.7.0

type MessageOptions struct {
	Output Writer
	Hint   string // Optional second line displayed in gray
}

MessageOptions configures simple message helpers output. If Output is nil, the helper functions are no-ops.

type MockReadable added in v0.7.0

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

func NewMockReadable added in v0.7.0

func NewMockReadable() *MockReadable

func (*MockReadable) Close added in v0.7.0

func (m *MockReadable) Close() error

func (*MockReadable) EmitKeypress added in v0.7.0

func (m *MockReadable) EmitKeypress(char string, key Key)

func (*MockReadable) EmitPaste added in v0.13.0

func (m *MockReadable) EmitPaste(content string)

EmitPaste simulates a bracketed paste event by emitting a Key with Name "paste".

func (*MockReadable) On added in v0.7.0

func (m *MockReadable) On(event string, handler func(string, Key))

func (*MockReadable) Read added in v0.7.0

func (m *MockReadable) Read(p []byte) (int, error)

func (*MockReadable) SendKey added in v0.7.0

func (m *MockReadable) SendKey(char string, key Key)

SendKey is a convenience method for testing.

type MockWritable added in v0.7.0

type MockWritable struct {
	Buffer []string
	// contains filtered or unexported fields
}

func NewMockWritable added in v0.7.0

func NewMockWritable() *MockWritable

func (*MockWritable) Emit added in v0.7.0

func (m *MockWritable) Emit(event string)

func (*MockWritable) GetFrames added in v0.7.0

func (m *MockWritable) GetFrames() []string

GetFrames returns all written frames for testing.

func (*MockWritable) On added in v0.7.0

func (m *MockWritable) On(event string, handler func())

func (*MockWritable) Write added in v0.7.0

func (m *MockWritable) Write(p []byte) (int, error)

type MultiSelectOptions added in v0.5.0

type MultiSelectOptions[T any] struct {
	Message       string
	Options       []SelectOption[T]
	InitialValues []T
	MaxItems      *int
	Input         Reader
	Output        Writer
}

MultiSelectOptions defines options for styled multi-select prompt.

type PasswordOptions

type PasswordOptions struct {
	Message      string
	DefaultValue string
	InitialValue string
	Validate     func(string) error
	Input        Reader
	Output       Writer
}

PasswordOptions defines options for styled password prompt.

type Progress added in v0.4.0

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

Progress represents a progress bar that wraps spinner functionality.

func NewProgress

func NewProgress(opts ProgressOptions) *Progress

NewProgress creates a new progress bar.

func (*Progress) Advance added in v0.4.0

func (p *Progress) Advance(step int, msg string)

Advance updates progress by the given step and optionally updates message.

func (*Progress) Message added in v0.4.0

func (p *Progress) Message(msg string)

Message updates the message without advancing progress.

func (*Progress) Start added in v0.4.0

func (p *Progress) Start(msg string)

Start begins the progress bar animation.

func (*Progress) Stop added in v0.4.0

func (p *Progress) Stop(msg string, code int, opts ...StopOptions)

Stop halts the progress bar and shows final state.

type ProgressOptions

type ProgressOptions struct {
	Style  string // "light", "heavy", "block"
	Max    int    // maximum value (default 100)
	Size   int    // bar width in characters (default 40)
	Output Writer
}

ProgressOptions configures the progress bar.

type Prompt added in v0.7.0

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

func NewPrompt added in v0.7.0

func NewPrompt(options PromptOptions) *Prompt

NewPrompt creates a new prompt instance with default tracking.

func NewPromptWithTracking added in v0.7.0

func NewPromptWithTracking(options PromptOptions, trackValue bool) *Prompt

NewPromptWithTracking creates a new prompt instance with specified tracking.

func (*Prompt) CursorSnapshot added in v0.7.0

func (p *Prompt) CursorSnapshot() int

func (*Prompt) Emit added in v0.7.0

func (p *Prompt) Emit(event string, args ...any)

Emit emits an event to all subscribers.

func (*Prompt) ErrorSnapshot added in v0.7.0

func (p *Prompt) ErrorSnapshot() string

func (*Prompt) On added in v0.7.0

func (p *Prompt) On(event string, handler any)

On subscribes to an event.

func (*Prompt) Prompt added in v0.7.0

func (p *Prompt) Prompt(ctx context.Context) any

Prompt starts the prompt and returns the result.

func (*Prompt) SetImmediateValue added in v0.7.0

func (p *Prompt) SetImmediateValue(v any)

SetImmediateValue updates the value in the current event-loop tick if possible. Falls back to enqueuing when called outside the loop.

func (*Prompt) SetValue added in v0.7.0

func (p *Prompt) SetValue(v any)

SetValue schedules a value update (for tests or programmatic flows). When called from within the event loop, it updates immediately. When called from outside, it enqueues an event.

func (*Prompt) StateSnapshot added in v0.7.0

func (p *Prompt) StateSnapshot() ClackState

func (*Prompt) UserInputSnapshot added in v0.7.0

func (p *Prompt) UserInputSnapshot() string

func (*Prompt) ValueSnapshot added in v0.7.0

func (p *Prompt) ValueSnapshot() any

type PromptOptions added in v0.7.0

type PromptOptions struct {
	Render           func(*Prompt) string
	InitialValue     any
	InitialUserInput string
	Validate         func(any) error
	Input            Reader
	Output           Writer
	Debug            bool
}

type Reader added in v0.7.0

type Reader interface {
	io.Reader
	On(event string, handler func(string, Key))
}

type SelectOption

type SelectOption[T any] struct {
	Value T
	Label string
	Hint  string
}

SelectOption represents an option in a styled select prompt.

type SelectOptions

type SelectOptions[T any] struct {
	Message      string
	Options      []SelectOption[T]
	InitialValue *T
	MaxItems     *int
	Input        Reader
	Output       Writer
}

SelectOptions defines options for styled select prompt.

type Spinner added in v0.4.0

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

Spinner represents an animated spinner.

func NewSpinner

func NewSpinner(opts SpinnerOptions) *Spinner

NewSpinner creates a new Spinner with defaults.

func (*Spinner) IsCancelled added in v0.4.0

func (s *Spinner) IsCancelled() bool

IsCancelled reports whether Stop was called with cancel code (1).

func (*Spinner) Message added in v0.4.0

func (s *Spinner) Message(msg string)

Message updates the spinner message for next frame.

func (*Spinner) Start added in v0.4.0

func (s *Spinner) Start(msg string)

Start begins the spinner animation.

func (*Spinner) Stop added in v0.4.0

func (s *Spinner) Stop(msg string, code int, opts ...StopOptions)

Stop halts the spinner and prints a final line with a status symbol code: 0 submit, 1 cancel, >1 error

type SpinnerOptions

type SpinnerOptions struct {
	Indicator     string   // "dots" (default) or "timer"
	Frames        []string // custom frames; defaults to unicode spinner frames
	Delay         time.Duration
	Output        Writer
	CancelMessage string
	ErrorMessage  string
}

SpinnerOptions configures the spinner behavior.

type StopOptions added in v0.12.0

type StopOptions struct {
	Hint string // Optional second line displayed in gray below the message
}

StopOptions configures the Stop behavior for Spinner and Progress.

type Stream added in v0.6.0

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

Stream renders a live stream area with clack-like styling Use Start to begin, WriteLine/Pipe to add content, and Stop to finalize.

func NewStream added in v0.6.0

func NewStream(opts StreamOptions) *Stream

NewStream creates a Stream.

func (*Stream) Pipe added in v0.6.0

func (s *Stream) Pipe(r io.Reader)

Pipe reads from r line-by-line and writes to the stream area.

func (*Stream) Start added in v0.6.0

func (s *Stream) Start(message string)

Start prints the header and prepares to receive lines.

func (*Stream) Stop added in v0.6.0

func (s *Stream) Stop(finalMessage string, code int)

Stop finalizes the stream with a status symbol and optional timer code: 0 submit, 1 cancel, >1 error

func (*Stream) WriteLine added in v0.6.0

func (s *Stream) WriteLine(line string)

WriteLine appends a single line into the stream area.

type StreamOptions added in v0.6.0

type StreamOptions struct {
	Output Writer
	// If true, show elapsed time on finalize line
	ShowTimer bool
}

StreamOptions configure the styled stream renderer.

type TableAlignment added in v0.9.0

type TableAlignment string
const (
	TableAlignLeft   TableAlignment = "left"
	TableAlignCenter TableAlignment = "center"
	TableAlignRight  TableAlignment = "right"
)

type TableColor added in v0.9.0

type TableColor string
const (
	TableColorDefault TableColor = "default"
	TableColorGray    TableColor = "gray"
	TableColorRed     TableColor = "red"
	TableColorGreen   TableColor = "green"
	TableColorYellow  TableColor = "yellow"
	TableColorCyan    TableColor = "cyan"
)

type TableOptions added in v0.9.0

type TableOptions struct {
	Output           Writer
	ShowBorders      bool
	IncludePrefix    bool
	MaxWidth         int
	ColumnAlignments []TableAlignment
	HeaderStyle      TableStyle
	HeaderColor      TableColor
	FormatBorder     func(string) string
}

TableOptions defines options for styled table rendering.

type TableStyle added in v0.9.0

type TableStyle string
const (
	TableStyleNormal TableStyle = "normal"
	TableStyleBold   TableStyle = "bold"
	TableStyleDim    TableStyle = "dim"
)

type TextOptions

type TextOptions struct {
	Message      string
	Placeholder  string
	DefaultValue string
	InitialValue string
	Validate     func(string) error
	Input        Reader
	Output       Writer
}

TextOptions defines options for styled text prompt.

type TextareaOptions added in v0.13.0

type TextareaOptions struct {
	Message      string
	Placeholder  string
	DefaultValue string
	InitialValue string
	Validate     func(string) error
	Input        Reader
	Output       Writer
}

TextareaOptions defines options for styled multiline text input prompt.

type ValidationError added in v0.7.0

type ValidationError struct {
	Message string
}

func NewValidationError added in v0.7.0

func NewValidationError(message string) *ValidationError

func (*ValidationError) Error added in v0.7.0

func (e *ValidationError) Error() string

type Writer added in v0.7.0

type Writer interface {
	io.Writer
	On(event string, handler func())
	Emit(event string)
}

Directories

Path Synopsis
examples
autocomplete command
confirm command
messages command
multiple command
multiselect command
password command
progress command
select command
spinner command
stream command
table command
text command
textarea command
internal

Jump to

Keyboard shortcuts

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