Documentation
¶
Index ¶
- Constants
- Variables
- func Ask(label string) (string, error)
- func AskChoice(label string, options ...string) (int, error)
- func AskConfirm(label string) (bool, error)
- func AskEmail(label string) (string, error)
- func AskMultiChoice(label string, options ...string) ([]int, error)
- func AskNumber(label string) (int, error)
- func AskPassword(label string) (string, error)
- func AskRequired(label string) (string, error)
- func AskWithCommandCompletion(label string) (string, error)
- func AskWithDefault(label, defaultValue string) (string, error)
- func AskWithFileCompletion(label string) (string, error)
- func AskWithOptions(label string, options []string) (string, error)
- func AutoComplete(config AutoCompleteConfig) (string, error)
- func Clear()
- func ClearLine()
- func Confirm(config ConfirmConfig) (bool, error)
- func DisableColors()
- func EmailValidator(email string) error
- func EnableColors()
- func ErrorBanner(message string)
- func ErrorBox(title, content string) string
- func ErrorLine(message string)
- func GetAvailableThemes() []string
- func GetOptimalColumns(contentWidth int) int
- func Gradient(text string, startColor, endColor *Color) string
- func Header(title string)
- func HideCursor()
- func InfoBanner(message string)
- func InfoBox(title, content string) string
- func InfoLine(message string)
- func Input(config InputConfig) (string, error)
- func IsLG() bool
- func IsMD() bool
- func IsMDOrLarger() bool
- func IsSM() bool
- func IsSMOrSmaller() bool
- func IsXL() bool
- func IsXS() bool
- func KeyValueTable(data map[string]string) string
- func MaxLengthValidator(max int) func(string) error
- func MinLengthValidator(min int) func(string) error
- func MoveCursorDown(n int)
- func MoveCursorUp(n int)
- func MultiSelect(config SelectConfig) ([]int, error)
- func NumberValidator(input string) error
- func PadString(s string, width int) string
- func PrintErrorBox(title, content string)
- func PrintInfoBox(title, content string)
- func PrintKeyValueTable(data map[string]string)
- func PrintSimpleBox(title, content string)
- func PrintSimpleTable(headers []string, rows [][]string)
- func PrintSuccessBox(title, content string)
- func PrintWarningBox(title, content string)
- func Rainbow(text string) string
- func Select(config SelectConfig) (int, error)
- func Separator()
- func SetTheme(themeName string) error
- func ShowAllThemes()
- func ShowCursor()
- func ShowProgress[T any](items []T, label string, fn func(T) error) error
- func ShowProgressWithStyle[T any](items []T, label string, style ProgressBarStyle, fn func(T) error) error
- func ShowSpinner(message string, fn func() error) error
- func ShowSpinnerWithStyle(style SpinnerStyle, message string, fn func() error) error
- func SimpleBox(title, content string) string
- func SimpleTable(headers []string, rows [][]string) string
- func SmartMargin() int
- func SmartPadding() int
- func SmartWidth(percentage float64) int
- func SuccessBanner(message string)
- func SuccessBox(title, content string) string
- func SuccessLine(message string)
- func ThemePreview(themeName string) error
- func TruncateString(s string, width int) string
- func URLValidator(url string) error
- func WarningBanner(message string)
- func WarningBox(title, content string) string
- func WarningLine(message string)
- type AutoCompleteBuilder
- func (b *AutoCompleteBuilder) Ask() (string, error)
- func (b *AutoCompleteBuilder) CaseSensitive(enabled bool) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) FuzzyMatch(enabled bool) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) Required(required bool) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) WithMaxResults(max int) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) WithMinLength(length int) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) WithOptions(options []string) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) WithPlaceholder(placeholder string) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) WithTransformer(transformer func(string) string) *AutoCompleteBuilder
- func (b *AutoCompleteBuilder) WithValidator(validator func(string) error) *AutoCompleteBuilder
- type AutoCompleteConfig
- type AutoCompleteResult
- type Banner
- func (b *Banner) Multiline(enable bool) *Banner
- func (b *Banner) Print()
- func (b *Banner) Println()
- func (b *Banner) Render() string
- func (b *Banner) WithBorderColor(color *Color) *Banner
- func (b *Banner) WithColor(color *Color) *Banner
- func (b *Banner) WithResponsiveConfig(config ResponsiveConfig) *Banner
- func (b *Banner) WithSmartWidth(percentage float64) *Banner
- func (b *Banner) WithStyle(style BannerStyle) *Banner
- func (b *Banner) WithWidth(width int) *Banner
- type BannerStyle
- type BannerType
- type BarChart
- func (bc *BarChart) AddData(label string, value float64, color *Color) *BarChart
- func (bc *BarChart) Print()
- func (bc *BarChart) Println()
- func (bc *BarChart) Render() string
- func (bc *BarChart) SetHorizontal(horizontal bool) *BarChart
- func (bc *BarChart) SetShowValues(show bool) *BarChart
- func (bc *BarChart) WithHeight(height int) *BarChart
- func (bc *BarChart) WithResponsiveConfig(config ResponsiveConfig) *BarChart
- func (bc *BarChart) WithSmartWidth(ratio float64) *BarChart
- func (bc *BarChart) WithWidth(width int) *BarChart
- type Box
- func (b *Box) AddEmptyLine() *Box
- func (b *Box) AddLine(line string) *Box
- func (b *Box) AddLines(lines ...string) *Box
- func (b *Box) AddSeparator() *Box
- func (b *Box) AddText(text string) *Box
- func (b *Box) AutoSize(enable bool) *Box
- func (b *Box) Clear() *Box
- func (b *Box) Print()
- func (b *Box) Println()
- func (b *Box) Render() string
- func (b *Box) ShowBorder(show bool) *Box
- func (b *Box) WithAlignment(alignment BoxAlignment) *Box
- func (b *Box) WithBorderColor(color *Color) *Box
- func (b *Box) WithColor(color *Color) *Box
- func (b *Box) WithHeight(height int) *Box
- func (b *Box) WithPadding(padding int) *Box
- func (b *Box) WithResponsiveConfig(config ResponsiveConfig) *Box
- func (b *Box) WithSmartWidth(percentage float64) *Box
- func (b *Box) WithStyle(style BoxStyle) *Box
- func (b *Box) WithTitle(title string) *Box
- func (b *Box) WithTitleColor(color *Color) *Box
- func (b *Box) WithWidth(width int) *Box
- type BoxAlignment
- type BoxStyle
- type Breakpoint
- type BreakpointSize
- type ChartData
- type Color
- func (c *Color) Disable() *Color
- func (c *Color) Enable() *Color
- func (c *Color) IsDisabled() bool
- func (c *Color) Print(s string)
- func (c *Color) Printf(format string, args ...interface{})
- func (c *Color) Println(s string)
- func (c *Color) Sprint(s string) string
- func (c *Color) Sprintf(format string, args ...interface{}) string
- type ColorFunc
- type ConfirmConfig
- type ElementConfig
- type Histogram
- type InputConfig
- type MultiBar
- type PieChart
- func (pc *PieChart) AddData(label string, value float64, color *Color) *PieChart
- func (pc *PieChart) Print()
- func (pc *PieChart) Println()
- func (pc *PieChart) Render() string
- func (pc *PieChart) SetShowLegend(show bool) *PieChart
- func (pc *PieChart) SetShowPercentages(show bool) *PieChart
- func (pc *PieChart) WithRadius(radius int) *PieChart
- type ProgressBar
- func (p *ProgressBar) Add(delta int64)
- func (p *ProgressBar) Finish()
- func (p *ProgressBar) GetCurrent() int64
- func (p *ProgressBar) GetTotal() int64
- func (p *ProgressBar) Increment()
- func (p *ProgressBar) IsFinished() bool
- func (p *ProgressBar) Print()
- func (p *ProgressBar) Println()
- func (p *ProgressBar) Render() string
- func (p *ProgressBar) Set(current int64)
- func (p *ProgressBar) SetTotal(total int64)
- func (p *ProgressBar) ShowCount(show bool) *ProgressBar
- func (p *ProgressBar) ShowETA(show bool) *ProgressBar
- func (p *ProgressBar) ShowPercent(show bool) *ProgressBar
- func (p *ProgressBar) ShowRate(show bool) *ProgressBar
- func (p *ProgressBar) WithBackgroundColor(color *Color) *ProgressBar
- func (p *ProgressBar) WithColor(color *Color) *ProgressBar
- func (p *ProgressBar) WithLabel(label string) *ProgressBar
- func (p *ProgressBar) WithResponsiveConfig(config ResponsiveConfig) *ProgressBar
- func (p *ProgressBar) WithSmartWidth(percentage float64) *ProgressBar
- func (p *ProgressBar) WithStyle(style ProgressBarStyle) *ProgressBar
- func (p *ProgressBar) WithWidth(width int) *ProgressBar
- type ProgressBarStyle
- type ResponsiveConfig
- type ResponsiveManager
- func (rm *ResponsiveManager) GetCurrentBreakpoint() BreakpointSize
- func (rm *ResponsiveManager) GetCurrentBreakpointName() string
- func (rm *ResponsiveManager) IsBreakpoint(size BreakpointSize) bool
- func (rm *ResponsiveManager) IsBreakpointOrLarger(size BreakpointSize) bool
- func (rm *ResponsiveManager) IsBreakpointOrSmaller(size BreakpointSize) bool
- func (rm *ResponsiveManager) RefreshBreakpoint()
- type SelectConfig
- type Spinner
- func (s *Spinner) Error(message string)
- func (s *Spinner) HideCursor(hide bool) *Spinner
- func (s *Spinner) Info(message string)
- func (s *Spinner) IsRunning() bool
- func (s *Spinner) Start() *Spinner
- func (s *Spinner) Stop()
- func (s *Spinner) Success(message string)
- func (s *Spinner) UpdateMessage(message string)
- func (s *Spinner) Warning(message string)
- func (s *Spinner) WithColor(color *Color) *Spinner
- func (s *Spinner) WithMessage(message string) *Spinner
- func (s *Spinner) WithPrefix(prefix string) *Spinner
- func (s *Spinner) WithStyle(style SpinnerStyle) *Spinner
- func (s *Spinner) WithSuffix(suffix string) *Spinner
- type SpinnerStyle
- type Table
- func (t *Table) AddColumn(header string) *Table
- func (t *Table) AddColumnWithConfig(column TableColumn) *Table
- func (t *Table) AddColumnWithWidth(header string, width int) *Table
- func (t *Table) AddRow(cells ...string) *Table
- func (t *Table) AddRows(rows [][]string) *Table
- func (t *Table) AutoResize(enable bool) *Table
- func (t *Table) Clear() *Table
- func (t *Table) Print()
- func (t *Table) Println()
- func (t *Table) Render() string
- func (t *Table) SetColumnAlignment(columnIndex int, alignment TableAlignment) *Table
- func (t *Table) SetColumnColor(columnIndex int, color *Color) *Table
- func (t *Table) ShowBorders(show bool) *Table
- func (t *Table) ShowHeader(show bool) *Table
- func (t *Table) WithBorderColor(color *Color) *Table
- func (t *Table) WithHeaderColor(color *Color) *Table
- func (t *Table) WithMaxWidth(width int) *Table
- func (t *Table) WithPadding(padding int) *Table
- func (t *Table) WithResponsiveConfig(config ResponsiveConfig) *Table
- func (t *Table) WithSmartWidth(percentage float64) *Table
- func (t *Table) WithStyle(style TableStyle) *Table
- type TableAlignment
- type TableColumn
- type TableStyle
- type Terminal
- type Theme
Constants ¶
const ( Reset = "\033[0m" Black = "\033[30m" Red = "\033[31m" Green = "\033[32m" Yellow = "\033[33m" Blue = "\033[34m" Magenta = "\033[35m" Cyan = "\033[36m" White = "\033[37m" BrightBlack = "\033[90m" BrightRed = "\033[91m" BrightGreen = "\033[92m" BrightYellow = "\033[93m" BrightBlue = "\033[94m" BrightMagenta = "\033[95m" BrightCyan = "\033[96m" BrightWhite = "\033[97m" BgBlack = "\033[40m" BgRed = "\033[41m" BgGreen = "\033[42m" BgYellow = "\033[43m" BgBlue = "\033[44m" BgMagenta = "\033[45m" BgCyan = "\033[46m" BgWhite = "\033[47m" Bold = "\033[1m" Dim = "\033[2m" Italic = "\033[3m" Underline = "\033[4m" Blink = "\033[5m" Reverse = "\033[7m" Strike = "\033[9m" )
const Version = "1.0.0"
Variables ¶
var ( BannerStyleDefault = BannerStyle{ TopLeft: "┌", TopRight: "┐", BottomLeft: "└", BottomRight: "┘", Horizontal: "─", Vertical: "│", Padding: 1, } BannerStyleRounded = BannerStyle{ TopLeft: "╭", TopRight: "╮", BottomLeft: "╰", BottomRight: "╯", Horizontal: "─", Vertical: "│", Padding: 1, } BannerStyleBold = BannerStyle{ TopLeft: "┏", TopRight: "┓", BottomLeft: "┗", BottomRight: "┛", Horizontal: "━", Vertical: "┃", Padding: 1, } BannerStyleDouble = BannerStyle{ TopLeft: "╔", TopRight: "╗", BottomLeft: "╚", BottomRight: "╝", Horizontal: "═", Vertical: "║", Padding: 1, } BannerStyleSimple = BannerStyle{ TopLeft: "+", TopRight: "+", BottomLeft: "+", BottomRight: "+", Horizontal: "-", Vertical: "|", Padding: 1, } )
var ( BoxStyleDefault = BoxStyle{ TopLeft: "┌", TopRight: "┐", BottomLeft: "└", BottomRight: "┘", Horizontal: "─", Vertical: "│", Cross: "┼", TopTee: "┬", BottomTee: "┴", LeftTee: "├", RightTee: "┤", } BoxStyleRounded = BoxStyle{ TopLeft: "╭", TopRight: "╮", BottomLeft: "╰", BottomRight: "╯", Horizontal: "─", Vertical: "│", Cross: "┼", TopTee: "┬", BottomTee: "┴", LeftTee: "├", RightTee: "┤", } BoxStyleBold = BoxStyle{ TopLeft: "┏", TopRight: "┓", BottomLeft: "┗", BottomRight: "┛", Horizontal: "━", Vertical: "┃", Cross: "╋", TopTee: "┳", BottomTee: "┻", LeftTee: "┣", RightTee: "┫", } BoxStyleDouble = BoxStyle{ TopLeft: "╔", TopRight: "╗", BottomLeft: "╚", BottomRight: "╝", Horizontal: "═", Vertical: "║", Cross: "╬", TopTee: "╦", BottomTee: "╩", LeftTee: "╠", RightTee: "╣", } BoxStyleSimple = BoxStyle{ TopLeft: "+", TopRight: "+", BottomLeft: "+", BottomRight: "+", Horizontal: "-", Vertical: "|", Cross: "+", TopTee: "+", BottomTee: "+", LeftTee: "+", RightTee: "+", } BoxStyleMinimal = BoxStyle{ TopLeft: " ", TopRight: " ", BottomLeft: " ", BottomRight: " ", Horizontal: " ", Vertical: " ", Cross: " ", TopTee: " ", BottomTee: " ", LeftTee: " ", RightTee: " ", } )
var ( BlackColor = NewColor(Black) RedColor = NewColor(Red) GreenColor = NewColor(Green) YellowColor = NewColor(Yellow) BlueColor = NewColor(Blue) MagentaColor = NewColor(Magenta) CyanColor = NewColor(Cyan) WhiteColor = NewColor(White) BrightBlackColor = NewColor(BrightBlack) BrightRedColor = NewColor(BrightRed) BrightGreenColor = NewColor(BrightGreen) BrightYellowColor = NewColor(BrightYellow) BrightBlueColor = NewColor(BrightBlue) BrightMagentaColor = NewColor(BrightMagenta) BrightCyanColor = NewColor(BrightCyan) BrightWhiteColor = NewColor(BrightWhite) BoldColor = NewColor(Bold) DimColor = NewColor(Dim) ItalicColor = NewColor(Italic) UnderlineColor = NewColor(Underline) BlinkColor = NewColor(Blink) ReverseColor = NewColor(Reverse) StrikeColor = NewColor(Strike) )
var ( Success = GreenColor Warning = YellowColor Error = RedColor Info = BlueColor Muted = DimColor )
var ( ProgressStyleDefault = ProgressBarStyle{ LeftBorder: "[", RightBorder: "]", Filled: "█", Empty: "░", Pointer: "", } ProgressStyleModern = ProgressBarStyle{ LeftBorder: "▐", RightBorder: "▌", Filled: "▓", Empty: "░", Pointer: "", } ProgressStyleArrow = ProgressBarStyle{ LeftBorder: "(", RightBorder: ")", Filled: "=", Empty: "-", Pointer: ">", } ProgressStyleDots = ProgressBarStyle{ LeftBorder: "[", RightBorder: "]", Filled: "●", Empty: "○", Pointer: "", } ProgressStyleBlock = ProgressBarStyle{ LeftBorder: "▕", RightBorder: "▏", Filled: "▉", Empty: " ", Pointer: "", } ProgressStyleGradient = ProgressBarStyle{ LeftBorder: "[", RightBorder: "]", Filled: "█", Empty: "▁", Pointer: "", } )
var ( SpinnerDots = SpinnerStyle{ Frames: []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}, Interval: 80 * time.Millisecond, } SpinnerLine = SpinnerStyle{ Frames: []string{"|", "/", "-", "\\"}, Interval: 100 * time.Millisecond, } SpinnerArrow = SpinnerStyle{ Frames: []string{"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"}, Interval: 120 * time.Millisecond, } SpinnerBounce = SpinnerStyle{ Frames: []string{"⠁", "⠂", "⠄", "⠂"}, Interval: 200 * time.Millisecond, } SpinnerClock = SpinnerStyle{ Frames: []string{"🕐", "🕑", "🕒", "🕓", "🕔", "🕕", "🕖", "🕗", "🕘", "🕙", "🕚", "🕛"}, Interval: 100 * time.Millisecond, } SpinnerEarth = SpinnerStyle{ Frames: []string{"🌍", "🌎", "🌏"}, Interval: 180 * time.Millisecond, } SpinnerMoon = SpinnerStyle{ Frames: []string{"🌑", "🌒", "🌓", "🌔", "🌕", "🌖", "🌗", "🌘"}, Interval: 80 * time.Millisecond, } SpinnerRunner = SpinnerStyle{ Frames: []string{"🚶", "🏃"}, Interval: 140 * time.Millisecond, } SpinnerPulse = SpinnerStyle{ Frames: []string{"●", "◐", "◑", "◒", "◓", "◔", "◕", "◖", "◗"}, Interval: 100 * time.Millisecond, } SpinnerGrowVertical = SpinnerStyle{ Frames: []string{"▁", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃"}, Interval: 120 * time.Millisecond, } )
var ( TableStyleDefault = TableStyle{ TopLeft: "┌", TopRight: "┐", BottomLeft: "└", BottomRight: "┘", Horizontal: "─", Vertical: "│", Cross: "┼", TopTee: "┬", BottomTee: "┴", LeftTee: "├", RightTee: "┤", } TableStyleRounded = TableStyle{ TopLeft: "╭", TopRight: "╮", BottomLeft: "╰", BottomRight: "╯", Horizontal: "─", Vertical: "│", Cross: "┼", TopTee: "┬", BottomTee: "┴", LeftTee: "├", RightTee: "┤", } TableStyleBold = TableStyle{ TopLeft: "┏", TopRight: "┓", BottomLeft: "┗", BottomRight: "┛", Horizontal: "━", Vertical: "┃", Cross: "╋", TopTee: "┳", BottomTee: "┻", LeftTee: "┣", RightTee: "┫", } TableStyleDouble = TableStyle{ TopLeft: "╔", TopRight: "╗", BottomLeft: "╚", BottomRight: "╝", Horizontal: "═", Vertical: "║", Cross: "╬", TopTee: "╦", BottomTee: "╩", LeftTee: "╠", RightTee: "╣", } TableStyleSimple = TableStyle{ TopLeft: "+", TopRight: "+", BottomLeft: "+", BottomRight: "+", Horizontal: "-", Vertical: "|", Cross: "+", TopTee: "+", BottomTee: "+", LeftTee: "+", RightTee: "+", } TableStyleMinimal = TableStyle{ TopLeft: " ", TopRight: " ", BottomLeft: " ", BottomRight: " ", Horizontal: " ", Vertical: " ", Cross: " ", TopTee: " ", BottomTee: " ", LeftTee: " ", RightTee: " ", } )
var ( DarkTheme = &Theme{ Name: "Dark", Primary: BrightBlueColor, Secondary: BrightCyanColor, Success: BrightGreenColor, Warning: BrightYellowColor, Error: BrightRedColor, Info: BrightBlueColor, Muted: DimColor, Background: BlackColor, Text: BrightWhiteColor, Border: BrightBlackColor, } LightTheme = &Theme{ Name: "Light", Primary: BlueColor, Secondary: CyanColor, Success: GreenColor, Warning: YellowColor, Error: RedColor, Info: BlueColor, Muted: BlackColor, Background: WhiteColor, Text: BlackColor, Border: BlackColor, } ColorfulTheme = &Theme{ Name: "Colorful", Primary: BrightMagentaColor, Secondary: BrightCyanColor, Success: BrightGreenColor, Warning: BrightYellowColor, Error: BrightRedColor, Info: BrightBlueColor, Muted: DimColor, Background: BlackColor, Text: BrightWhiteColor, Border: BrightMagentaColor, } MinimalTheme = &Theme{ Name: "Minimal", Primary: WhiteColor, Secondary: DimColor, Success: WhiteColor, Warning: WhiteColor, Error: WhiteColor, Info: WhiteColor, Muted: DimColor, Background: BlackColor, Text: WhiteColor, Border: DimColor, } OceanTheme = &Theme{ Name: "Ocean", Primary: RGB(0, 150, 255), Secondary: RGB(0, 200, 200), Success: RGB(0, 255, 150), Warning: RGB(255, 200, 0), Error: RGB(255, 100, 100), Info: RGB(100, 200, 255), Muted: RGB(100, 100, 150), Background: RGB(5, 25, 50), Text: RGB(200, 230, 255), Border: RGB(50, 100, 150), } )
var BooleanOptions = []string{"yes", "no", "true", "false", "y", "n"}
var ( Breakpoints = []Breakpoint{ {BreakpointXS, 0, 59, "xs", false}, {BreakpointSM, 60, 79, "sm", false}, {BreakpointMD, 80, 119, "md", false}, {BreakpointLG, 120, 159, "lg", false}, {BreakpointXL, 160, 999, "xl", false}, } )
var ColorOptions = []string{
"red", "green", "blue", "yellow", "cyan", "magenta", "white", "black",
"gray", "orange", "pink", "purple", "brown", "lime", "navy", "teal",
}
var PriorityOptions = []string{"low", "medium", "high", "critical", "urgent", "normal"}
var SizeOptions = []string{"small", "medium", "large", "xl", "xs", "xxl", "tiny", "huge"}
var StatusOptions = []string{
"active", "inactive", "pending", "completed", "failed", "cancelled",
"draft", "published", "archived", "deleted",
}
Functions ¶
func AskConfirm ¶
AskConfirm prompts for a yes/no confirmation
func AskMultiChoice ¶
AskMultiChoice prompts for multiple choices from options
func AskPassword ¶
AskPassword prompts for a masked password input
func AskRequired ¶
AskRequired prompts for a required text input
func AskWithCommandCompletion ¶
AskWithCommandCompletion prompts with common command completion
func AskWithDefault ¶
AskWithDefault prompts for text input with a default value
func AskWithFileCompletion ¶
AskWithFileCompletion prompts for a file path with file completion
func AskWithOptions ¶
AskWithOptions prompts for input with predefined options
func AutoComplete ¶
func AutoComplete(config AutoCompleteConfig) (string, error)
AutoComplete prompts for input with autocomplete functionality
func Confirm ¶
func Confirm(config ConfirmConfig) (bool, error)
Confirm shows a yes/no confirmation prompt
func EmailValidator ¶
func ErrorBanner ¶
func ErrorBanner(message string)
ErrorBanner creates and displays an error banner
func GetAvailableThemes ¶ added in v1.1.0
func GetAvailableThemes() []string
GetAvailableThemes returns a list of available theme names
func GetOptimalColumns ¶ added in v1.1.0
GetOptimalColumns returns optimal number of columns for current screen size
func IsMDOrLarger ¶ added in v1.1.0
func IsMDOrLarger() bool
func IsSMOrSmaller ¶ added in v1.1.0
func IsSMOrSmaller() bool
func KeyValueTable ¶
KeyValueTable creates a two-column key-value table
func MaxLengthValidator ¶
func MinLengthValidator ¶
func MultiSelect ¶
func MultiSelect(config SelectConfig) ([]int, error)
MultiSelect shows a multi-selection prompt with arrow key navigation
func NumberValidator ¶
func PrintKeyValueTable ¶
PrintKeyValueTable prints a key-value table
func PrintSimpleTable ¶
PrintSimpleTable prints a simple table
func PrintSuccessBox ¶
func PrintSuccessBox(title, content string)
PrintSuccessBox prints a success box
func PrintWarningBox ¶
func PrintWarningBox(title, content string)
PrintWarningBox prints a warning box
func Select ¶
func Select(config SelectConfig) (int, error)
Select shows a single selection prompt with arrow key navigation
func ShowAllThemes ¶ added in v1.1.0
func ShowAllThemes()
ShowAllThemes displays previews of all available themes
func ShowProgress ¶
ShowProgress shows a progress bar for a slice operation
func ShowProgressWithStyle ¶
func ShowProgressWithStyle[T any](items []T, label string, style ProgressBarStyle, fn func(T) error) error
ShowProgressWithStyle shows a progress bar with custom style
func ShowSpinner ¶
ShowSpinner shows a spinner with a message and runs the provided function
func ShowSpinnerWithStyle ¶
func ShowSpinnerWithStyle(style SpinnerStyle, message string, fn func() error) error
ShowSpinnerWithStyle shows a spinner with custom style, message and runs the provided function
func SimpleTable ¶
SimpleTable creates a simple table from headers and rows
func SmartMargin ¶ added in v1.1.0
func SmartMargin() int
SmartMargin returns appropriate margin based on screen size
func SmartPadding ¶ added in v1.1.0
func SmartPadding() int
SmartPadding returns appropriate padding based on screen size
func SmartWidth ¶ added in v1.1.0
SmartWidth sizing functions
func SuccessBanner ¶
func SuccessBanner(message string)
SuccessBanner creates and displays a success banner
func SuccessBox ¶
SuccessBox creates a success-styled box
func SuccessLine ¶
func SuccessLine(message string)
SuccessLine prints a simple success message with icon
func ThemePreview ¶ added in v1.1.0
ThemePreview shows a preview of a theme
func TruncateString ¶
TruncateString truncates a string to the specified width with ellipsis using visual width calculation
func URLValidator ¶
func WarningBanner ¶
func WarningBanner(message string)
WarningBanner creates and displays a warning banner
func WarningBox ¶
WarningBox creates a warning-styled box
func WarningLine ¶
func WarningLine(message string)
WarningLine prints a simple warning message with icon
Types ¶
type AutoCompleteBuilder ¶
type AutoCompleteBuilder struct {
// contains filtered or unexported fields
}
func NewAutoCompleteBuilder ¶
func NewAutoCompleteBuilder(label string) *AutoCompleteBuilder
NewAutoCompleteBuilder creates a new autocomplete builder
func (*AutoCompleteBuilder) Ask ¶
func (b *AutoCompleteBuilder) Ask() (string, error)
Ask executes the autocomplete prompt
func (*AutoCompleteBuilder) CaseSensitive ¶
func (b *AutoCompleteBuilder) CaseSensitive(enabled bool) *AutoCompleteBuilder
CaseSensitive enables case-sensitive matching
func (*AutoCompleteBuilder) FuzzyMatch ¶
func (b *AutoCompleteBuilder) FuzzyMatch(enabled bool) *AutoCompleteBuilder
FuzzyMatch enables fuzzy matching
func (*AutoCompleteBuilder) Required ¶
func (b *AutoCompleteBuilder) Required(required bool) *AutoCompleteBuilder
Required makes the input required
func (*AutoCompleteBuilder) WithMaxResults ¶
func (b *AutoCompleteBuilder) WithMaxResults(max int) *AutoCompleteBuilder
WithMaxResults sets the maximum number of suggestions to show
func (*AutoCompleteBuilder) WithMinLength ¶
func (b *AutoCompleteBuilder) WithMinLength(length int) *AutoCompleteBuilder
WithMinLength sets the minimum input length before showing suggestions
func (*AutoCompleteBuilder) WithOptions ¶
func (b *AutoCompleteBuilder) WithOptions(options []string) *AutoCompleteBuilder
WithOptions sets the autocomplete options
func (*AutoCompleteBuilder) WithPlaceholder ¶
func (b *AutoCompleteBuilder) WithPlaceholder(placeholder string) *AutoCompleteBuilder
WithPlaceholder sets the placeholder text
func (*AutoCompleteBuilder) WithTransformer ¶
func (b *AutoCompleteBuilder) WithTransformer(transformer func(string) string) *AutoCompleteBuilder
WithTransformer sets a transformation function
func (*AutoCompleteBuilder) WithValidator ¶
func (b *AutoCompleteBuilder) WithValidator(validator func(string) error) *AutoCompleteBuilder
WithValidator sets a validation function
type AutoCompleteConfig ¶
type AutoCompleteResult ¶
type Banner ¶
type Banner struct {
ResponsiveConfig *ResponsiveConfig
// contains filtered or unexported fields
}
func CustomBanner ¶
func CustomBanner(message string, textColor, borderColor *Color, style BannerStyle) *Banner
CustomBanner creates a custom banner with specific colors and style
func NewBanner ¶
func NewBanner(message string, bannerType BannerType) *Banner
NewBanner creates a new banner
func ThemedBanner ¶ added in v1.1.0
func ThemedBanner(message string, bannerType BannerType) *Banner
ThemedBanner creates a banner using current theme colors
func (*Banner) Println ¶
func (b *Banner) Println()
Println renders and prints the banner with a newline
func (*Banner) WithBorderColor ¶
WithBorderColor sets the border color
func (*Banner) WithResponsiveConfig ¶ added in v1.1.0
func (b *Banner) WithResponsiveConfig(config ResponsiveConfig) *Banner
WithResponsiveConfig sets responsive configuration for different breakpoints
func (*Banner) WithSmartWidth ¶ added in v1.1.0
WithSmartWidth enables smart responsive width sizing
func (*Banner) WithStyle ¶
func (b *Banner) WithStyle(style BannerStyle) *Banner
WithStyle sets the banner style
type BannerStyle ¶
type BannerType ¶
type BannerType int
const ( BannerSuccess BannerType = iota BannerWarning BannerError BannerInfo )
type BarChart ¶ added in v1.1.0
type BarChart struct {
Title string
Data []ChartData
Width int
Height int
MaxValue float64
ShowValues bool
Horizontal bool
ResponsiveConfig *ResponsiveConfig
// contains filtered or unexported fields
}
BarChart represents a bar chart
func NewBarChart ¶ added in v1.1.0
NewBarChart creates a new bar chart
func (*BarChart) Print ¶ added in v1.1.0
func (bc *BarChart) Print()
Print renders and prints the chart
func (*BarChart) Println ¶ added in v1.1.0
func (bc *BarChart) Println()
Println renders and prints the chart with newline
func (*BarChart) SetHorizontal ¶ added in v1.1.0
SetHorizontal sets chart orientation
func (*BarChart) SetShowValues ¶ added in v1.1.0
SetShowValues toggles value display
func (*BarChart) WithHeight ¶ added in v1.1.0
WithHeight sets the chart height (for horizontal charts)
func (*BarChart) WithResponsiveConfig ¶ added in v1.1.0
func (bc *BarChart) WithResponsiveConfig(config ResponsiveConfig) *BarChart
WithResponsiveConfig sets responsive configuration
func (*BarChart) WithSmartWidth ¶ added in v1.1.0
WithSmartWidth sets responsive width
type Box ¶
type Box struct {
ResponsiveConfig *ResponsiveConfig
// contains filtered or unexported fields
}
func (*Box) AddSeparator ¶
AddSeparator adds a horizontal separator line
func (*Box) ShowBorder ¶
ShowBorder controls whether to show the border
func (*Box) WithAlignment ¶
func (b *Box) WithAlignment(alignment BoxAlignment) *Box
WithAlignment sets the text alignment
func (*Box) WithBorderColor ¶
WithBorderColor sets the border color
func (*Box) WithPadding ¶
WithPadding sets the internal padding
func (*Box) WithResponsiveConfig ¶ added in v1.1.0
func (b *Box) WithResponsiveConfig(config ResponsiveConfig) *Box
WithResponsiveConfig sets responsive configuration for different breakpoints
func (*Box) WithSmartWidth ¶ added in v1.1.0
WithSmartWidth enables smart responsive width sizing
func (*Box) WithTitleColor ¶
WithTitleColor sets the title color
type BoxAlignment ¶
type BoxAlignment int
const ( BoxAlignLeft BoxAlignment = iota BoxAlignCenter BoxAlignRight )
type Breakpoint ¶ added in v1.1.0
type Breakpoint struct {
Size BreakpointSize
MinWidth int
MaxWidth int
Name string
IsActive bool
}
type BreakpointSize ¶ added in v1.1.0
type BreakpointSize int
const ( BreakpointXS BreakpointSize = iota // < 60 chars BreakpointSM // 60-79 chars BreakpointMD // 80 - 119 chars BreakpointLG // 120 - 159 chars BreakpointXL // >= 160 chars )
type Color ¶
type Color struct {
// contains filtered or unexported fields
}
func (*Color) IsDisabled ¶
IsDisabled returns true if color is disabled
type ConfirmConfig ¶
type ElementConfig ¶ added in v1.1.0
type ElementConfig struct {
Width *int
Height *int
Padding *int
Margin *int
ShowFull bool
Compact bool
}
ElementConfig defines element configuration per breakpoint
type Histogram ¶ added in v1.1.2
Histogram creates a simple histogram
func NewHistogram ¶ added in v1.1.2
NewHistogram creates a new histogram
func (*Histogram) Print ¶ added in v1.1.2
func (h *Histogram) Print()
Print renders and prints the histogram
func (*Histogram) Println ¶ added in v1.1.2
func (h *Histogram) Println()
Println renders and prints the histogram with newline
type InputConfig ¶
type MultiBar ¶
type MultiBar struct {
// contains filtered or unexported fields
}
MultiBar represents multiple progress bars
func (*MultiBar) AddBar ¶
func (m *MultiBar) AddBar(bar *ProgressBar) *MultiBar
AddBar adds a progress bar to the multi-bar
type PieChart ¶ added in v1.1.2
type PieChart struct {
Title string
Data []ChartData
Radius int
ShowPercentages bool
ShowLegend bool
ResponsiveConfig *ResponsiveConfig
}
PieChart represents a pie chart
func NewPieChart ¶ added in v1.1.2
NewPieChart creates a new pie chart
func (*PieChart) Print ¶ added in v1.1.2
func (pc *PieChart) Print()
Print renders and prints the pie chart
func (*PieChart) Println ¶ added in v1.1.2
func (pc *PieChart) Println()
Println renders and prints the pie chart with newline
func (*PieChart) SetShowLegend ¶ added in v1.1.2
SetShowLegend toggles legend display
func (*PieChart) SetShowPercentages ¶ added in v1.1.2
SetShowPercentages toggles percentage display
func (*PieChart) WithRadius ¶ added in v1.1.2
WithRadius sets the pie chart radius
type ProgressBar ¶
type ProgressBar struct {
ResponsiveConfig *ResponsiveConfig
// contains filtered or unexported fields
}
func NewProgressBar ¶
func NewProgressBar(total int64) *ProgressBar
NewProgressBar creates a new progress bar
func (*ProgressBar) Add ¶
func (p *ProgressBar) Add(delta int64)
Add increments the current progress by the given amount
func (*ProgressBar) GetCurrent ¶
func (p *ProgressBar) GetCurrent() int64
GetCurrent returns the current progress value
func (*ProgressBar) GetTotal ¶
func (p *ProgressBar) GetTotal() int64
GetTotal returns the total progress value
func (*ProgressBar) Increment ¶
func (p *ProgressBar) Increment()
Increment increments the current progress by 1
func (*ProgressBar) IsFinished ¶
func (p *ProgressBar) IsFinished() bool
IsFinished returns true if the progress bar is finished
func (*ProgressBar) Println ¶
func (p *ProgressBar) Println()
Println renders and prints the progress bar with a newline
func (*ProgressBar) Render ¶
func (p *ProgressBar) Render() string
Render renders the progress bar and returns the string representation
func (*ProgressBar) Set ¶
func (p *ProgressBar) Set(current int64)
Set sets the current progress value
func (*ProgressBar) SetTotal ¶
func (p *ProgressBar) SetTotal(total int64)
SetTotal sets a new total value
func (*ProgressBar) ShowCount ¶
func (p *ProgressBar) ShowCount(show bool) *ProgressBar
ShowCount controls whether to show count (current/total)
func (*ProgressBar) ShowETA ¶
func (p *ProgressBar) ShowETA(show bool) *ProgressBar
ShowETA controls whether to show estimated time of arrival
func (*ProgressBar) ShowPercent ¶
func (p *ProgressBar) ShowPercent(show bool) *ProgressBar
ShowPercent controls whether to show percentage
func (*ProgressBar) ShowRate ¶
func (p *ProgressBar) ShowRate(show bool) *ProgressBar
ShowRate controls whether to show rate (items/sec)
func (*ProgressBar) WithBackgroundColor ¶
func (p *ProgressBar) WithBackgroundColor(color *Color) *ProgressBar
WithBackgroundColor sets the background color
func (*ProgressBar) WithColor ¶
func (p *ProgressBar) WithColor(color *Color) *ProgressBar
WithColor sets the progress bar color
func (*ProgressBar) WithLabel ¶
func (p *ProgressBar) WithLabel(label string) *ProgressBar
WithLabel sets a label for the progress bar
func (*ProgressBar) WithResponsiveConfig ¶ added in v1.1.0
func (p *ProgressBar) WithResponsiveConfig(config ResponsiveConfig) *ProgressBar
WithResponsiveConfig sets responsive configuration for different breakpoints
func (*ProgressBar) WithSmartWidth ¶ added in v1.1.0
func (p *ProgressBar) WithSmartWidth(percentage float64) *ProgressBar
WithSmartWidth enables smart responsive width sizing
func (*ProgressBar) WithStyle ¶
func (p *ProgressBar) WithStyle(style ProgressBarStyle) *ProgressBar
WithStyle sets the progress bar style
func (*ProgressBar) WithWidth ¶
func (p *ProgressBar) WithWidth(width int) *ProgressBar
WithWidth sets the progress bar width
type ProgressBarStyle ¶
type ResponsiveConfig ¶ added in v1.1.0
type ResponsiveConfig struct {
XS *ElementConfig
SM *ElementConfig
MD *ElementConfig
LG *ElementConfig
XL *ElementConfig
}
ResponsiveConfig holds responsive configuration for elements
func (*ResponsiveConfig) GetConfigForBreakpoint ¶ added in v1.1.0
func (rc *ResponsiveConfig) GetConfigForBreakpoint(bp BreakpointSize) *ElementConfig
GetConfigForBreakpoint returns the appropriate config for current breakpoint
type ResponsiveManager ¶ added in v1.1.0
type ResponsiveManager struct {
// contains filtered or unexported fields
}
ResponsiveManager handles responsive behavior
func GetResponsiveManager ¶ added in v1.1.0
func GetResponsiveManager() *ResponsiveManager
GetResponsiveManager returns the global responsive manager singleton
func NewResponsiveManager ¶ added in v1.1.0
func NewResponsiveManager() *ResponsiveManager
NewResponsiveManager creates a new responsive manager
func (*ResponsiveManager) GetCurrentBreakpoint ¶ added in v1.1.0
func (rm *ResponsiveManager) GetCurrentBreakpoint() BreakpointSize
GetCurrentBreakpoint returns the current active breakpoint
func (*ResponsiveManager) GetCurrentBreakpointName ¶ added in v1.1.0
func (rm *ResponsiveManager) GetCurrentBreakpointName() string
GetCurrentBreakpointName returns the current breakpoint name
func (*ResponsiveManager) IsBreakpoint ¶ added in v1.1.0
func (rm *ResponsiveManager) IsBreakpoint(size BreakpointSize) bool
IsBreakpoint checks if current breakpoint matches given size
func (*ResponsiveManager) IsBreakpointOrLarger ¶ added in v1.1.0
func (rm *ResponsiveManager) IsBreakpointOrLarger(size BreakpointSize) bool
IsBreakpointOrLarger checks if current breakpoint is size or larger
func (*ResponsiveManager) IsBreakpointOrSmaller ¶ added in v1.1.0
func (rm *ResponsiveManager) IsBreakpointOrSmaller(size BreakpointSize) bool
IsBreakpointOrSmaller checks if current breakpoint is size or smaller
func (*ResponsiveManager) RefreshBreakpoint ¶ added in v1.1.0
func (rm *ResponsiveManager) RefreshBreakpoint()
RefreshBreakpoint manually refreshes the current breakpoint
type SelectConfig ¶
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
func NewSpinner ¶
func NewSpinner() *Spinner
NewSpinner creates a new spinner with the default style
func (*Spinner) HideCursor ¶
HideCursor controls whether to hide the cursor while spinning
func (*Spinner) UpdateMessage ¶
UpdateMessage updates the spinner message while it's running
func (*Spinner) WithMessage ¶
WithMessage sets the spinner message
func (*Spinner) WithPrefix ¶
WithPrefix sets a prefix for the spinner
func (*Spinner) WithStyle ¶
func (s *Spinner) WithStyle(style SpinnerStyle) *Spinner
WithStyle sets the spinner style
func (*Spinner) WithSuffix ¶
WithSuffix sets a suffix for the spinner
type SpinnerStyle ¶
type Table ¶
type Table struct {
ResponsiveConfig *ResponsiveConfig
// contains filtered or unexported fields
}
func (*Table) AddColumnWithConfig ¶
func (t *Table) AddColumnWithConfig(column TableColumn) *Table
AddColumnWithConfig adds a column with full configuration
func (*Table) AddColumnWithWidth ¶
AddColumnWithWidth adds a column with a specific width
func (*Table) AutoResize ¶
AutoResize controls whether to auto-resize columns
func (*Table) Println ¶
func (t *Table) Println()
Println renders and prints the table with a newline
func (*Table) SetColumnAlignment ¶
func (t *Table) SetColumnAlignment(columnIndex int, alignment TableAlignment) *Table
SetColumnAlignment sets the alignment for a specific column
func (*Table) SetColumnColor ¶
SetColumnColor sets the color for a specific column
func (*Table) ShowBorders ¶
ShowBorders controls whether to show borders
func (*Table) ShowHeader ¶
ShowHeader controls whether to show the header row
func (*Table) WithBorderColor ¶
WithBorderColor sets the border color
func (*Table) WithHeaderColor ¶
WithHeaderColor sets the header text color
func (*Table) WithMaxWidth ¶
WithMaxWidth sets the maximum table width
func (*Table) WithPadding ¶
WithPadding sets the cell padding
func (*Table) WithResponsiveConfig ¶ added in v1.1.0
func (t *Table) WithResponsiveConfig(config ResponsiveConfig) *Table
WithResponsiveConfig sets responsive configuration for different breakpoints
func (*Table) WithSmartWidth ¶ added in v1.1.0
WithSmartWidth enables smart responsive width sizing
func (*Table) WithStyle ¶
func (t *Table) WithStyle(style TableStyle) *Table
WithStyle sets the table style
type TableAlignment ¶
type TableAlignment int
const ( AlignLeft TableAlignment = iota AlignCenter AlignRight )
type TableColumn ¶
type TableColumn struct {
Header string
Width int
Alignment TableAlignment
Color *Color
}
type TableStyle ¶
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}