components

package
v0.9.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package components provides reusable UI components for the CLI

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Confirm

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

Confirm represents a yes/no confirmation prompt

func NewConfirm

func NewConfirm(message string) *Confirm

NewConfirm creates a new confirmation prompt with the given message

func (*Confirm) Run

func (c *Confirm) Run() (bool, error)

Run runs the confirmation prompt and returns the user's choice

func (*Confirm) WithDefault

func (c *Confirm) WithDefault(value bool) *Confirm

WithDefault sets the default value for the confirmation

type Progress

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

Progress represents a progress bar with message

func NewProgress

func NewProgress(total, width int) *Progress

NewProgress creates a new progress bar with the given total and width

func (*Progress) Complete

func (p *Progress) Complete(message string)

Complete marks the progress bar as completed

func (*Progress) Error

func (p *Progress) Error(message string)

Error shows an error message and stops the progress bar

func (*Progress) Update

func (p *Progress) Update(current int, message string)

Update updates the progress bar with the current value and message

type Prompt

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

Prompt represents a user input prompt

func NewPrompt

func NewPrompt(label string) *Prompt

NewPrompt creates a new prompt with the given label

func (*Prompt) Run

func (p *Prompt) Run() (string, error)

Run runs the prompt and returns the user's input

func (*Prompt) WithValidator

func (p *Prompt) WithValidator(validator func(string) error) *Prompt

WithValidator adds a validator function to the prompt

type Select

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

Select represents a selection prompt

func NewSelect

func NewSelect(label string, items []string) *Select

NewSelect creates a new selection prompt with the given label and items

func (*Select) Run

func (s *Select) Run() (string, int, error)

Run runs the selection prompt and returns the selected item and index

func (*Select) WithSelected

func (s *Select) WithSelected(index int) *Select

WithSelected sets the default selected item

type Spinner

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

Spinner represents a loading spinner with message

func NewSpinner

func NewSpinner(message string) *Spinner

NewSpinner creates a new spinner with the given message

func (*Spinner) Error

func (s *Spinner) Error(message string)

Error stops the spinner and shows an error message

func (*Spinner) Info

func (s *Spinner) Info(message string)

Info stops the spinner and shows an info message

func (*Spinner) Start

func (s *Spinner) Start()

Start starts the spinner

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the spinner

func (*Spinner) Success

func (s *Spinner) Success(message string)

Success stops the spinner and shows a success message

func (*Spinner) UpdateMessage

func (s *Spinner) UpdateMessage(message string)

UpdateMessage updates the spinner message

func (*Spinner) Warning

func (s *Spinner) Warning(message string)

Warning stops the spinner and shows a warning message

type Table

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

Table represents a formatted table for CLI output

func NewTable

func NewTable() *Table

NewTable creates a new CLI table

func (*Table) AddHeader

func (t *Table) AddHeader(headers ...string)

AddHeader adds column headers to the table

func (*Table) AddRow

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

AddRow adds a row to the table

func (*Table) Render

func (t *Table) Render() error

Render prints the table to stdout

func (*Table) RenderToString

func (t *Table) RenderToString() string

RenderToString returns the table as a string

func (*Table) WithStyle

func (t *Table) WithStyle(style TableStyle) *Table

WithStyle sets custom styling for the table

type TableStyle

type TableStyle struct {
	HeaderStyle   func(string) string
	CellStyle     func(string) string
	BorderStyle   func(string) string
	ShowBorders   bool
	ColumnPadding int
}

TableStyle represents the styling options for a table

func DefaultTableStyle

func DefaultTableStyle() TableStyle

DefaultTableStyle returns the default table styling

Jump to

Keyboard shortcuts

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