Documentation
¶
Index ¶
- Constants
- func Box(message string, title string, opts BoxOptions)
- func Cancel(message string, opts ...MessageOptions)
- func Confirm(opts ConfirmOptions) any
- func CyanBorder(s string) string
- func GrayBorder(s string) string
- func Intro(title string, opts ...MessageOptions)
- func Outro(message string, opts ...MessageOptions)
- func Password(opts PasswordOptions) any
- func Select[T any](opts SelectOptions[T]) any
- func Symbol(state core.ClackState) string
- func Text(opts TextOptions) any
- type BoxAlignment
- type BoxOptions
- type ConfirmOptions
- type MessageOptions
- type PasswordOptions
- type Progress
- type ProgressOptions
- type Reader
- type SelectOption
- type SelectOptions
- type Spinner
- type SpinnerOptions
- type TextOptions
- type Writer
Constants ¶
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 = "○" )
Unicode symbols for drawing styled prompts
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" Inverse = "\033[7m" Strikethrough = "\033[9m" )
ANSI color codes
Variables ¶
This section is empty.
Functions ¶
func Box ¶
func Box(message string, 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 CyanBorder ¶
func Intro ¶
func Intro(title string, opts ...MessageOptions)
Intro prints an intro title (bar start + title).
func Outro ¶
func Outro(message string, opts ...MessageOptions)
Outro prints a final outro (bar line, then bar end + message).
func Password ¶ added in v0.2.0
func Password(opts PasswordOptions) any
Password creates a styled password input prompt that masks user input
func Symbol ¶
func Symbol(state core.ClackState) string
Symbol returns the appropriate symbol for a given state with color
Types ¶
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 ConfirmOptions ¶
type ConfirmOptions struct {
Message string
Active string
Inactive string
InitialValue bool
Input core.Reader
Output core.Writer
}
ConfirmOptions defines options for styled confirm prompt
type MessageOptions ¶
type MessageOptions struct {
Output Writer
}
MessageOptions configures simple message helpers output. If Output is nil, the helper functions are no-ops.
type PasswordOptions ¶ added in v0.2.0
type PasswordOptions struct {
Message string
DefaultValue string
InitialValue string
Validate func(string) error
Input core.Reader
Output core.Writer
}
PasswordOptions defines options for styled password prompt
type Progress ¶
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 ¶
Advance updates progress by the given step and optionally updates message
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 SelectOption ¶
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 core.Reader Output core.Writer }
SelectOptions defines options for styled select prompt
type Spinner ¶ added in v0.2.0
type Spinner struct {
// contains filtered or unexported fields
}
Spinner represents an animated spinner
func NewSpinner ¶ added in v0.2.0
func NewSpinner(opts SpinnerOptions) *Spinner
NewSpinner creates a new Spinner with defaults
func (*Spinner) IsCancelled ¶ added in v0.2.0
IsCancelled reports whether Stop was called with cancel code (1)
type SpinnerOptions ¶ added in v0.2.0
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