clime

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 15 Imported by: 2

README

Clime 🎨

A beautiful and feature-rich Command Line Interface library for Go that makes building stunning terminal applications effortless.

Go Version License Version

✨ Features

Clime provides a comprehensive set of tools for creating beautiful command-line interfaces:

🎯 Core Components
  • Terminal Utilities - Clear screen, cursor movement, size detection
  • Rich Colors & Formatting - 16+ colors, bold, italic, underline, rainbow effects
  • Interactive Spinners - Multiple styles with customizable colors and messages
  • Progress Bars - Single and multi-bar support with ETA and rate display
  • Styled Banners - Success, warning, error, and info messages
  • Data Tables - Formatted tables with column styling and alignment
  • Decorative Boxes - Multiple border styles with titles and content wrapping
  • User Input - Text, password, email, number, and confirmation prompts
  • Autocomplete - Smart suggestions with fuzzy matching
🎨 Visual Elements
  • Spinner Styles: Default, Clock, Dots, Arrow, Modern
  • Progress Styles: Modern, Arrow, Dots, Classic
  • Box Styles: Default, Rounded, Bold, Double
  • Banner Types: Success, Warning, Error, Info with custom icons
  • Color Support: Full palette including bright colors and gradients
  • Theme System: 5 predefined themes with customizable colors
🖥️ Platform Support
  • Cross-platform: Windows, macOS, Linux
  • Terminal Detection: Automatic TTY detection and sizing
  • Responsive Design: Adapts to terminal width and height

📦 Installation

go get github.com/alperdrsnn/clime

🚀 Quick Start

package main

import (
    "fmt"
    "time"
    "github.com/alperdrsnn/clime"
)

func main() {
    // Welcome header
    clime.Header("Welcome to My App")
    
    // Colored messages
    clime.SuccessLine("Application started successfully!")
    clime.InfoLine("Loading configuration...")
    
    // Spinner with custom message
    spinner := clime.NewSpinner().
        WithMessage("Initializing...").
        WithColor(clime.BlueColor).
        Start()
    time.Sleep(2 * time.Second)
    spinner.Success("Initialization complete!")
    
    // Progress bar
    bar := clime.NewProgressBar(100).
        WithLabel("Processing").
        ShowETA(true)
        
    for i := 0; i <= 100; i += 10 {
        bar.Set(int64(i))
        bar.Print()
        time.Sleep(200 * time.Millisecond)
    }
    bar.Finish()
    
    // Interactive input
    name, _ := clime.Ask("What's your name?")
    clime.SuccessLine(fmt.Sprintf("Hello, %s! 👋", name))
    
    // Responsive box that adapts to terminal size
    clime.NewBox().
        WithTitle("Responsive Demo").
        WithSmartWidth(0.8).  // 80% of terminal width
        AddLine("This box adapts to your terminal size!").
        AddLine("Try resizing your terminal and running again.").
        Println()
}

📚 Usage Examples

Colors and Text Formatting
// Basic colors
fmt.Println(clime.Success.Sprint("Success message"))
fmt.Println(clime.Warning.Sprint("Warning message"))
fmt.Println(clime.Error.Sprint("Error message"))
fmt.Println(clime.Info.Sprint("Info message"))

// Text styling
fmt.Println(clime.BoldColor.Sprint("Bold text"))
fmt.Println(clime.UnderlineColor.Sprint("Underlined text"))
fmt.Println(clime.Rainbow("Rainbow text!"))
Spinners
// Basic spinner
spinner := clime.NewSpinner().
    WithMessage("Loading...").
    Start()
time.Sleep(2 * time.Second)
spinner.Success("Done!")

// Styled spinner
spinner2 := clime.NewSpinner().
    WithStyle(clime.SpinnerClock).
    WithColor(clime.MagentaColor).
    WithMessage("Processing...").
    Start()
time.Sleep(3 * time.Second)
spinner2.Success("Complete!")
Progress Bars
// Single progress bar
bar := clime.NewProgressBar(100).
    WithLabel("Download").
    WithStyle(clime.ProgressStyleModern).
    WithColor(clime.GreenColor).
    ShowRate(true)

for i := 0; i <= 100; i += 5 {
    bar.Set(int64(i))
    bar.Print()
    time.Sleep(100 * time.Millisecond)
}
bar.Finish()

time.Sleep(1500 * time.Millisecond)
clime.Clear()

// Multi-progress bars
multiBar := clime.NewMultiBar()
bar1 := clime.NewProgressBar(100).WithLabel("Task 1")
bar2 := clime.NewProgressBar(80).WithLabel("Task 2")
multiBar.AddBar(bar1).AddBar(bar2)

for i := 0; i <= 100; i += 2 {
    if i <= 100 {
        bar1.Set(int64(i))
    }
    if i <= 80 {
        bar2.Set(int64(i))
    }
    multiBar.Print()
    time.Sleep(50 * time.Millisecond)
}
Tables
table := clime.NewTable().
    AddColumn("Name").
    AddColumn("Status").
    AddColumn("Progress").
    SetColumnColor(1, clime.Success).
    AddRow("Task 1", "Completed", "100%").
    AddRow("Task 2", "In Progress", "75%").
    AddRow("Task 3", "Pending", "0%")

table.Print()
Boxes
// Simple box
box := clime.NewBox().
    WithTitle("Information").
    WithBorderColor(clime.BlueColor).
    WithStyle(clime.BoxStyleRounded).
    AddLine("System Status: Online").
    AddLine("Version: 1.0.0").
    AddText("This is a longer description that will be automatically wrapped.")

box.Println()

// Quick boxes
clime.PrintSuccessBox("Success", "Operation completed!")
clime.PrintWarningBox("Warning", "Check your configuration.")
clime.PrintErrorBox("Error", "Something went wrong.")
Interactive Input
// Basic input
name, err := clime.Ask("Enter your name:")

// Email validation
email, err := clime.AskEmail("Enter your email:")

// Password input (masked)
password, err := clime.AskPassword("Enter password:")

// Number input
age, err := clime.AskNumber("Enter your age:")

// Confirmation
confirmed, err := clime.AskConfirm("Continue?", true)

// Single choice with arrow key navigation
frameworks := []string{"React", "Vue", "Angular", "Svelte"}
choice, err := clime.AskChoice("Select framework:", frameworks...)

// Multi-choice with arrow key navigation
languages := []string{"Go", "JavaScript", "Python", "Rust"}
choices, err := clime.AskMultiChoice("Select languages:", languages...)

// Autocomplete with arrow key navigation
options := []string{"apple", "banana", "cherry", "date"}
choice, err := clime.AskWithOptions("Choose a fruit:", options)

// Advanced autocomplete
choice, err := clime.AutoComplete(clime.AutoCompleteConfig{
    Label: "Choose a fruit:",
    Options: options,
    FuzzyMatch: true,
    MaxResults: 5,
})
Responsive Design
// Smart width sizing (adapts to terminal width)
clime.NewBox().
    WithTitle("Responsive Box").
    WithSmartWidth(0.7).  // 70% of terminal width
    AddLine("This box adapts to terminal size").
    Println()

// Breakpoint-specific configurations
box := clime.NewBox().
    WithTitle("Multi-Breakpoint Box").
    WithResponsiveConfig(clime.ResponsiveConfig{
        XS: &clime.ElementConfig{Width: 30, Padding: 1, Compact: true},
        SM: &clime.ElementConfig{Width: 50, Padding: 2},
        MD: &clime.ElementConfig{Width: 70, Padding: 2},
        LG: &clime.ElementConfig{Width: 90, Padding: 3},
        XL: &clime.ElementConfig{Width: 120, Padding: 3, ShowFull: true},
    }).
    AddLine("Width and padding change based on terminal size").
    AddLine("Try resizing your terminal and running again!")

box.Println()

// Responsive utility functions
if clime.IsXS() {
    clime.InfoLine("Very small terminal detected - using compact layout")
} else if clime.IsMDOrLarger() {
    clime.InfoLine("Large terminal detected - using full layout")
}

// Smart spacing
padding := clime.SmartPadding()  // 0-2 based on screen size
margin := clime.SmartMargin()    // 1-8 based on screen size

// Optimal column calculation
columns := clime.GetOptimalColumns(20)  // Content width: 20 chars
fmt.Printf("Optimal columns for this terminal: %d\n", columns)

// Manual refresh after terminal resize
rm := clime.GetResponsiveManager()
rm.RefreshBreakpoint()
fmt.Printf("Current breakpoint: %s\n", rm.GetCurrentBreakpointName())
Banners
clime.SuccessBanner("Operation completed successfully!")
clime.WarningBanner("Please review the following items.")
clime.ErrorBanner("Failed to connect to the server.")
clime.InfoBanner("New update available.")

// Custom banner
clime.NewBanner("Custom Message", clime.BannerInfo).
    WithStyle(clime.BannerStyleDouble).
    WithColor(clime.CyanColor).
    Println()
Charts
clime.NewBarChart("Sales by Region").
    AddData("North", 85.5, clime.BlueColor).
    AddData("South", 72.3, clime.GreenColor).
    AddData("East", 91.2, clime.YellowColor).
    AddData("West", 68.7, clime.RedColor).
    AddData("Central", 79.4, clime.MagentaColor).
    SetHorizontal(true).
    SetShowValues(true).
    Println()
Terminal Utilities
// Terminal information
terminal := clime.NewTerminal()
width := terminal.Width()
height := terminal.Height()
isInteractive := terminal.IsATTY()

// Screen control
clime.Clear()                    // Clear screen
clime.HideCursor()              // Hide cursor
clime.ShowCursor()              // Show cursor
clime.MoveCursorUp(3)           // Move cursor up 3 lines
clime.ClearLine()               // Clear current line

🎛️ Configuration Options

Spinner Styles
  • SpinnerDefault - Classic spinning animation
  • SpinnerClock - Clock-like rotation
  • SpinnerDots - Bouncing dots
  • SpinnerArrow - Rotating arrow
Progress Bar Styles
  • ProgressStyleModern - Clean modern look
  • ProgressStyleArrow - Arrow-based indicator
  • ProgressStyleDots - Dotted progress
  • ProgressStyleClassic - Traditional bar
Box Styles
  • BoxStyleDefault - Standard borders
  • BoxStyleRounded - Rounded corners
  • BoxStyleBold - Thick borders
  • BoxStyleDouble - Double-line borders
Banner Styles
  • BannerStyleSingle - Single line border
  • BannerStyleDouble - Double line border
  • BannerStyleThick - Thick border

🎨 Color Palette

Clime supports a full range of colors:

Standard Colors: Black, Red, Green, Yellow, Blue, Magenta, Cyan, White Bright Colors: BrightRed, BrightGreen, BrightYellow, BrightBlue, etc. Special Effects: Rainbow text, gradients, background colors

📱 Responsive Design System

Clime includes a comprehensive responsive design system that adapts UI components to different terminal sizes, ensuring optimal user experience across various environments.

🎯 Breakpoint System

The responsive system uses 5 breakpoints to categorize terminal widths:

XS: 0-59 chars    // Very small (mobile terminal, narrow SSH)
SM: 60-79 chars   // Small (default terminal)  
MD: 80-119 chars  // Medium (standard terminal)
LG: 120-159 chars // Large (wide terminal)
XL: 160+ chars    // Extra Large (ultra-wide displays)
🛠️ Smart Sizing Functions
SmartWidth

Automatically calculates element width based on terminal size and breakpoint:

// 80% of terminal width with smart margins
box := clime.NewBox().WithSmartWidth(0.8)
SmartPadding & SmartMargin

Adaptive spacing that scales with screen size:

// XS: 0 padding, SM: 1, MD: 1, LG: 2, XL: 2
padding := clime.SmartPadding()

// XS: 1 margin, SM: 2, MD: 4, LG: 6, XL: 8  
margin := clime.SmartMargin()
🎛️ Responsive Configuration

Define different configurations for each breakpoint:

box := clime.NewBox().
    WithTitle("Responsive Box").
    WithResponsiveConfig(clime.ResponsiveConfig{
        XS: &clime.ElementConfig{Width: 30, Padding: 1, Compact: true},
        SM: &clime.ElementConfig{Width: 40, Padding: 2},
        MD: &clime.ElementConfig{Width: 60, Padding: 2},
        LG: &clime.ElementConfig{Width: 80, Padding: 3},
        XL: &clime.ElementConfig{Width: 100, Padding: 3, ShowFull: true},
    })
🔧 Utility Functions
// Breakpoint detection
if clime.IsXS() {
    // Compact layout for very small terminals
} else if clime.IsMDOrLarger() {
    // Full-featured layout for larger terminals
}

// Optimal column calculation
columns := clime.GetOptimalColumns(contentWidth)
// XS: max 1, SM: max 2, MD: max 3, LG: max 4, XL: max 6

// Manual breakpoint refresh (after terminal resize)
rm := clime.GetResponsiveManager()
rm.RefreshBreakpoint()
🎪 Use Cases

Perfect for:

  • Dashboard Applications: Different layouts for different screen sizes
  • Data Visualization: Adaptive tables and charts
  • Interactive CLIs: Responsive menus and forms
  • Monitoring Tools: Compact vs detailed views

Example scenarios:

  • SSH terminal (narrow) → Compact, single-column layout
  • Standard terminal → Balanced layout with moderate spacing
  • Ultra-wide display → Multi-column layout with generous spacing
🚀 Future Enhancements
  • Live Responsive Updates: Real-time adaptation without restart
  • Custom Breakpoints: User-defined breakpoint values
  • Responsive Tables: Column hiding/showing based on width
  • Adaptive Spinners: Size-appropriate loading indicators
  • Smart Text Wrapping: Intelligent content reflow

Supported Features

✅ Current Features
  • Terminal Management: Screen clearing, cursor control, size detection
  • Color System: 16+ colors, text styling, rainbow effects
  • Spinners: 4+ styles with customizable colors and messages
  • Progress Bars: Single and multi-bar with ETA/rate display
  • Data Tables: Column styling, alignment, color support
  • Decorative Boxes: 4+ border styles with title support
  • Interactive Prompts: Text, password, email, number input with arrow key navigation
  • Autocomplete: Fuzzy matching, customizable options
  • Banners: Success, warning, error, info with icons
  • Cross-platform: Windows, macOS, Linux support
  • Windows Integration: Native Windows API for improved terminal size detection
  • TTY Detection: Automatic terminal capability detection
  • Text Utilities: Padding, truncation, wrapping
  • Multiple Input Types: Confirmation, selection, validation
  • Responsive Design: Breakpoint-based adaptive layouts and smart sizing
  • Theme System: Predefined color themes and custom theme support
  • Chart Components: Simple ASCII charts and graphs
🚧 Planned Features (TODO)
  • Enhanced Tables: Row separators and advanced formatting
  • Live Responsive Updates: Real-time terminal resize detection and adaptation
  • Responsive Tables: Column hiding/showing based on terminal width
  • Custom Breakpoints: User-defined breakpoint values and responsive rules
  • Advanced Layouts: Grid systems and complex UI layouts
  • Animation System: Custom animations and transitions
  • Configuration Files: JSON/YAML configuration support
  • Logging Integration: Built-in logging with styled output
  • Plugin System: Extensible component architecture
  • Interactive Menus: Navigation menus and selection interfaces

🤝 Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
Development Setup
# Clone the repository
git clone https://github.com/alperdrsnn/clime.git
cd clime

# Install dependencies
go mod tidy

# Run examples
go run examples/basic_example.go
go run examples/interactive_example.go
go run examples/advanced_example.go

Documentation

Index

Constants

View Source
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"
)
View Source
const Version = "1.0.0"

Variables

View Source
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,
	}
)
View Source
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:    " ",
	}
)
View Source
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)
)
View Source
var (
	Success = GreenColor
	Warning = YellowColor
	Error   = RedColor
	Info    = BlueColor
	Muted   = DimColor
)
View Source
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:     "",
	}
)
View Source
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,
	}
)
View Source
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:    " ",
	}
)
View Source
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),
	}
)
View Source
var BooleanOptions = []string{"yes", "no", "true", "false", "y", "n"}
View Source
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},
	}
)
View Source
var ColorOptions = []string{
	"red", "green", "blue", "yellow", "cyan", "magenta", "white", "black",
	"gray", "orange", "pink", "purple", "brown", "lime", "navy", "teal",
}
View Source
var PriorityOptions = []string{"low", "medium", "high", "critical", "urgent", "normal"}
View Source
var SizeOptions = []string{"small", "medium", "large", "xl", "xs", "xxl", "tiny", "huge"}
View Source
var StatusOptions = []string{
	"active", "inactive", "pending", "completed", "failed", "cancelled",
	"draft", "published", "archived", "deleted",
}

Functions

func Ask

func Ask(label string) (string, error)

Ask prompts for a simple text input

func AskChoice

func AskChoice(label string, options ...string) (int, error)

AskChoice prompts for a single choice from options

func AskConfirm

func AskConfirm(label string) (bool, error)

AskConfirm prompts for a yes/no confirmation

func AskEmail

func AskEmail(label string) (string, error)

AskEmail prompts for an email with validation

func AskMultiChoice

func AskMultiChoice(label string, options ...string) ([]int, error)

AskMultiChoice prompts for multiple choices from options

func AskNumber

func AskNumber(label string) (int, error)

AskNumber prompts for a number input

func AskPassword

func AskPassword(label string) (string, error)

AskPassword prompts for a masked password input

func AskRequired

func AskRequired(label string) (string, error)

AskRequired prompts for a required text input

func AskWithCommandCompletion

func AskWithCommandCompletion(label string) (string, error)

AskWithCommandCompletion prompts with common command completion

func AskWithDefault

func AskWithDefault(label, defaultValue string) (string, error)

AskWithDefault prompts for text input with a default value

func AskWithFileCompletion

func AskWithFileCompletion(label string) (string, error)

AskWithFileCompletion prompts for a file path with file completion

func AskWithOptions

func AskWithOptions(label string, options []string) (string, error)

AskWithOptions prompts for input with predefined options

func AutoComplete

func AutoComplete(config AutoCompleteConfig) (string, error)

AutoComplete prompts for input with autocomplete functionality

func Clear

func Clear()

Clear clears the terminal screen

func ClearLine

func ClearLine()

ClearLine clears the current line

func Confirm

func Confirm(config ConfirmConfig) (bool, error)

Confirm shows a yes/no confirmation prompt

func DisableColors

func DisableColors()

DisableColors globally disables color output

func EmailValidator

func EmailValidator(email string) error

func EnableColors

func EnableColors()

EnableColors globally enables color output

func ErrorBanner

func ErrorBanner(message string)

ErrorBanner creates and displays an error banner

func ErrorBox

func ErrorBox(title, content string) string

ErrorBox creates an error-styled box

func ErrorLine

func ErrorLine(message string)

ErrorLine prints a simple error message with icon

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

func GetOptimalColumns(contentWidth int) int

GetOptimalColumns returns optimal number of columns for current screen size

func Gradient

func Gradient(text string, startColor, endColor *Color) string

Gradient creates a gradient effect across text

func Header(title string)

Header creates a header-style banner

func HideCursor

func HideCursor()

HideCursor hides the terminal cursor

func InfoBanner

func InfoBanner(message string)

InfoBanner creates and displays an info banner

func InfoBox

func InfoBox(title, content string) string

InfoBox creates an info-styled box

func InfoLine

func InfoLine(message string)

InfoLine prints a simple info message with icon

func Input

func Input(config InputConfig) (string, error)

Input shows a text input prompt

func IsLG added in v1.1.0

func IsLG() bool

func IsMD added in v1.1.0

func IsMD() bool

func IsMDOrLarger added in v1.1.0

func IsMDOrLarger() bool

func IsSM added in v1.1.0

func IsSM() bool

func IsSMOrSmaller added in v1.1.0

func IsSMOrSmaller() bool

func IsXL added in v1.1.0

func IsXL() bool

func IsXS added in v1.1.0

func IsXS() bool

func KeyValueTable

func KeyValueTable(data map[string]string) string

KeyValueTable creates a two-column key-value table

func MaxLengthValidator

func MaxLengthValidator(max int) func(string) error

func MinLengthValidator

func MinLengthValidator(min int) func(string) error

func MoveCursorDown

func MoveCursorDown(n int)

MoveCursorDown moves the cursor down by n lines

func MoveCursorUp

func MoveCursorUp(n int)

MoveCursorUp moves the cursor up by n lines

func MultiSelect

func MultiSelect(config SelectConfig) ([]int, error)

MultiSelect shows a multi-selection prompt with arrow key navigation

func NumberValidator

func NumberValidator(input string) error

func PadString

func PadString(s string, width int) string

PadString pads a string to the specified width using visual width calculation

func PrintErrorBox

func PrintErrorBox(title, content string)

PrintErrorBox prints an error box

func PrintInfoBox

func PrintInfoBox(title, content string)

PrintInfoBox prints an info box

func PrintKeyValueTable

func PrintKeyValueTable(data map[string]string)

PrintKeyValueTable prints a key-value table

func PrintSimpleBox

func PrintSimpleBox(title, content string)

PrintSimpleBox prints a simple box

func PrintSimpleTable

func PrintSimpleTable(headers []string, rows [][]string)

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 Rainbow

func Rainbow(text string) string

Rainbow applies rainbow colors to text

func Select

func Select(config SelectConfig) (int, error)

Select shows a single selection prompt with arrow key navigation

func Separator

func Separator()

Separator prints a simple separator line

func SetTheme added in v1.1.0

func SetTheme(themeName string) error

SetTheme sets the active theme by name

func ShowAllThemes added in v1.1.0

func ShowAllThemes()

ShowAllThemes displays previews of all available themes

func ShowCursor

func ShowCursor()

ShowCursor shows the terminal cursor

func ShowProgress

func ShowProgress[T any](items []T, label string, fn func(T) error) error

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

func ShowSpinner(message string, fn func() error) error

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 SimpleBox

func SimpleBox(title, content string) string

SimpleBox creates a simple box with content

func SimpleTable

func SimpleTable(headers []string, rows [][]string) string

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

func SmartWidth(percentage float64) int

SmartWidth sizing functions

func SuccessBanner

func SuccessBanner(message string)

SuccessBanner creates and displays a success banner

func SuccessBox

func SuccessBox(title, content string) string

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

func ThemePreview(themeName string) error

ThemePreview shows a preview of a theme

func TruncateString

func TruncateString(s string, width int) string

TruncateString truncates a string to the specified width with ellipsis using visual width calculation

func URLValidator

func URLValidator(url string) error

func WarningBanner

func WarningBanner(message string)

WarningBanner creates and displays a warning banner

func WarningBox

func WarningBox(title, content string) string

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 AutoCompleteConfig struct {
	Label         string
	Placeholder   string
	Options       []string
	MinLength     int
	MaxResults    int
	CaseSensitive bool
	FuzzyMatch    bool
	Required      bool
	Validate      func(string) error
	Transform     func(string) string
}

type AutoCompleteResult

type AutoCompleteResult struct {
	Value string
	Score int
	Index int
}
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) Multiline

func (b *Banner) Multiline(enable bool) *Banner

Multiline controls whether to use multiline layout for long messages

func (*Banner) Print

func (b *Banner) Print()

Print renders and prints the banner

func (*Banner) Println

func (b *Banner) Println()

Println renders and prints the banner with a newline

func (*Banner) Render

func (b *Banner) Render() string

Render renders the banner and returns the string representation

func (*Banner) WithBorderColor

func (b *Banner) WithBorderColor(color *Color) *Banner

WithBorderColor sets the border color

func (*Banner) WithColor

func (b *Banner) WithColor(color *Color) *Banner

WithColor sets the text 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

func (b *Banner) WithSmartWidth(percentage float64) *Banner

WithSmartWidth enables smart responsive width sizing

func (*Banner) WithStyle

func (b *Banner) WithStyle(style BannerStyle) *Banner

WithStyle sets the banner style

func (*Banner) WithWidth

func (b *Banner) WithWidth(width int) *Banner

WithWidth sets the banner width

type BannerStyle

type BannerStyle struct {
	TopLeft     string
	TopRight    string
	BottomLeft  string
	BottomRight string
	Horizontal  string
	Vertical    string
	Padding     int
}

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

func NewBarChart(title string) *BarChart

NewBarChart creates a new bar chart

func (*BarChart) AddData added in v1.1.0

func (bc *BarChart) AddData(label string, value float64, color *Color) *BarChart

AddData adds data to the 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) Render added in v1.1.0

func (bc *BarChart) Render() string

Render generates the chart string

func (*BarChart) SetHorizontal added in v1.1.0

func (bc *BarChart) SetHorizontal(horizontal bool) *BarChart

SetHorizontal sets chart orientation

func (*BarChart) SetShowValues added in v1.1.0

func (bc *BarChart) SetShowValues(show bool) *BarChart

SetShowValues toggles value display

func (*BarChart) WithHeight added in v1.1.0

func (bc *BarChart) WithHeight(height int) *BarChart

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

func (bc *BarChart) WithSmartWidth(ratio float64) *BarChart

WithSmartWidth sets responsive width

func (*BarChart) WithWidth added in v1.1.0

func (bc *BarChart) WithWidth(width int) *BarChart

WithWidth sets the chart width

type Box

type Box struct {
	ResponsiveConfig *ResponsiveConfig
	// contains filtered or unexported fields
}

func NewBox

func NewBox() *Box

NewBox creates a new box

func (*Box) AddEmptyLine

func (b *Box) AddEmptyLine() *Box

AddEmptyLine adds an empty line

func (*Box) AddLine

func (b *Box) AddLine(line string) *Box

AddLine adds a single line of content

func (*Box) AddLines

func (b *Box) AddLines(lines ...string) *Box

AddLines adds multiple lines of content

func (*Box) AddSeparator

func (b *Box) AddSeparator() *Box

AddSeparator adds a horizontal separator line

func (*Box) AddText

func (b *Box) AddText(text string) *Box

AddText adds text content, automatically wrapping long lines

func (*Box) AutoSize

func (b *Box) AutoSize(enable bool) *Box

AutoSize controls whether to auto-size the box

func (*Box) Clear

func (b *Box) Clear() *Box

Clear clears all content

func (*Box) Print

func (b *Box) Print()

Print renders and prints the box

func (*Box) Println

func (b *Box) Println()

Println renders and prints the box with a newline

func (*Box) Render

func (b *Box) Render() string

Render renders the box and returns the string representation

func (*Box) ShowBorder

func (b *Box) ShowBorder(show bool) *Box

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

func (b *Box) WithBorderColor(color *Color) *Box

WithBorderColor sets the border color

func (*Box) WithColor

func (b *Box) WithColor(color *Color) *Box

WithColor sets the text color

func (*Box) WithHeight

func (b *Box) WithHeight(height int) *Box

WithHeight sets the box height

func (*Box) WithPadding

func (b *Box) WithPadding(padding int) *Box

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

func (b *Box) WithSmartWidth(percentage float64) *Box

WithSmartWidth enables smart responsive width sizing

func (*Box) WithStyle

func (b *Box) WithStyle(style BoxStyle) *Box

WithStyle sets the box style

func (*Box) WithTitle

func (b *Box) WithTitle(title string) *Box

WithTitle sets the box title

func (*Box) WithTitleColor

func (b *Box) WithTitleColor(color *Color) *Box

WithTitleColor sets the title color

func (*Box) WithWidth

func (b *Box) WithWidth(width int) *Box

WithWidth sets the box width

type BoxAlignment

type BoxAlignment int
const (
	BoxAlignLeft BoxAlignment = iota
	BoxAlignCenter
	BoxAlignRight
)

type BoxStyle

type BoxStyle struct {
	TopLeft     string
	TopRight    string
	BottomLeft  string
	BottomRight string
	Horizontal  string
	Vertical    string
	Cross       string
	TopTee      string
	BottomTee   string
	LeftTee     string
	RightTee    string
}

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 ChartData added in v1.1.0

type ChartData struct {
	Label string
	Value float64
	Color *Color
}

ChartData represents data for charts

type Color

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

func Combine

func Combine(codes ...string) *Color

Combine combines multiple color codes

func Hex

func Hex(hex string) *Color

Hex creates a color from a hex string (e.g., "#FF0000" or "FF0000")

func NewColor

func NewColor(code string) *Color

NewColor creates a new color with the given ANSI code

func RGB

func RGB(r, g, b int) *Color

RGB creates a color from RGB values (0-255)

func (*Color) Disable

func (c *Color) Disable() *Color

Disable disables color output for this color

func (*Color) Enable

func (c *Color) Enable() *Color

Enable enables color output for this color

func (*Color) IsDisabled

func (c *Color) IsDisabled() bool

IsDisabled returns true if color is disabled

func (*Color) Print

func (c *Color) Print(s string)

Print prints the colored string to stdout

func (*Color) Printf

func (c *Color) Printf(format string, args ...interface{})

Printf prints the formatted colored string to stdout

func (*Color) Println

func (c *Color) Println(s string)

Println prints the colored string with a newline

func (*Color) Sprint

func (c *Color) Sprint(s string) string

Sprint applies the color to a string and returns it

func (*Color) Sprintf

func (c *Color) Sprintf(format string, args ...interface{}) string

Sprintf applies the color to a formatted string

type ColorFunc

type ColorFunc func(string) string

type ConfirmConfig

type ConfirmConfig struct {
	Label   string
	Default bool
}

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

type Histogram struct {
	Title string
	Data  []float64
	Bins  int
	Width int
	Color *Color
}

Histogram creates a simple histogram

func NewHistogram added in v1.1.2

func NewHistogram(title string, data []float64) *Histogram

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

func (*Histogram) Render added in v1.1.2

func (h *Histogram) Render() string

Render generates the histogram string

func (*Histogram) WithBins added in v1.1.2

func (h *Histogram) WithBins(bins int) *Histogram

WithBins sets the number of bins

func (*Histogram) WithColor added in v1.1.2

func (h *Histogram) WithColor(color *Color) *Histogram

WithColor sets the histogram color

func (*Histogram) WithWidth added in v1.1.2

func (h *Histogram) WithWidth(width int) *Histogram

WithWidth sets the histogram width

type InputConfig

type InputConfig struct {
	Label       string
	Placeholder string
	Default     string
	Required    bool
	Mask        bool
	Validate    func(string) error
	Transform   func(string) string
}

type MultiBar

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

MultiBar represents multiple progress bars

func NewMultiBar

func NewMultiBar() *MultiBar

NewMultiBar creates a new multi-progress bar

func (*MultiBar) AddBar

func (m *MultiBar) AddBar(bar *ProgressBar) *MultiBar

AddBar adds a progress bar to the multi-bar

func (*MultiBar) Print

func (m *MultiBar) Print()

Print renders and prints all progress bars

func (*MultiBar) Println

func (m *MultiBar) Println()

Println renders and prints all progress bars with a final newline

func (*MultiBar) Render

func (m *MultiBar) Render() string

Render renders all progress bars

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

func NewPieChart(title string) *PieChart

NewPieChart creates a new pie chart

func (*PieChart) AddData added in v1.1.2

func (pc *PieChart) AddData(label string, value float64, color *Color) *PieChart

AddData adds data to the 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) Render added in v1.1.2

func (pc *PieChart) Render() string

Render generates the pie chart string

func (*PieChart) SetShowLegend added in v1.1.2

func (pc *PieChart) SetShowLegend(show bool) *PieChart

SetShowLegend toggles legend display

func (*PieChart) SetShowPercentages added in v1.1.2

func (pc *PieChart) SetShowPercentages(show bool) *PieChart

SetShowPercentages toggles percentage display

func (*PieChart) WithRadius added in v1.1.2

func (pc *PieChart) WithRadius(radius int) *PieChart

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) Finish

func (p *ProgressBar) Finish()

Finish completes the progress bar

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) Print

func (p *ProgressBar) Print()

Print renders and prints the progress bar

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 ProgressBarStyle struct {
	LeftBorder  string
	RightBorder string
	Filled      string
	Empty       string
	Pointer     string
}

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 SelectConfig struct {
	Label    string
	Options  []string
	Default  int
	Multiple bool
}

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) Error

func (s *Spinner) Error(message string)

Error stops the spinner and shows an error message

func (*Spinner) HideCursor

func (s *Spinner) HideCursor(hide bool) *Spinner

HideCursor controls whether to hide the cursor while spinning

func (*Spinner) Info

func (s *Spinner) Info(message string)

Info stops the spinner and shows an info message

func (*Spinner) IsRunning

func (s *Spinner) IsRunning() bool

IsRunning returns true if the spinner is currently running

func (*Spinner) Start

func (s *Spinner) Start() *Spinner

Start starts the spinner animation

func (*Spinner) Stop

func (s *Spinner) Stop()

Stop stops the spinner animation

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 while it's running

func (*Spinner) Warning

func (s *Spinner) Warning(message string)

Warning stops the spinner and shows a warning message

func (*Spinner) WithColor

func (s *Spinner) WithColor(color *Color) *Spinner

WithColor sets the spinner color

func (*Spinner) WithMessage

func (s *Spinner) WithMessage(message string) *Spinner

WithMessage sets the spinner message

func (*Spinner) WithPrefix

func (s *Spinner) WithPrefix(prefix string) *Spinner

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

func (s *Spinner) WithSuffix(suffix string) *Spinner

WithSuffix sets a suffix for the spinner

type SpinnerStyle

type SpinnerStyle struct {
	Frames   []string
	Interval time.Duration
}

type Table

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

func NewTable

func NewTable() *Table

NewTable creates a new table

func (*Table) AddColumn

func (t *Table) AddColumn(header string) *Table

AddColumn adds a column to the table

func (*Table) AddColumnWithConfig

func (t *Table) AddColumnWithConfig(column TableColumn) *Table

AddColumnWithConfig adds a column with full configuration

func (*Table) AddColumnWithWidth

func (t *Table) AddColumnWithWidth(header string, width int) *Table

AddColumnWithWidth adds a column with a specific width

func (*Table) AddRow

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

AddRow adds a row to the table

func (*Table) AddRows

func (t *Table) AddRows(rows [][]string) *Table

AddRows adds multiple rows to the table

func (*Table) AutoResize

func (t *Table) AutoResize(enable bool) *Table

AutoResize controls whether to auto-resize columns

func (*Table) Clear

func (t *Table) Clear() *Table

Clear clears all rows from the table

func (*Table) Print

func (t *Table) Print()

Print renders and prints the table

func (*Table) Println

func (t *Table) Println()

Println renders and prints the table with a newline

func (*Table) Render

func (t *Table) Render() string

Render renders the table and returns the string representation

func (*Table) SetColumnAlignment

func (t *Table) SetColumnAlignment(columnIndex int, alignment TableAlignment) *Table

SetColumnAlignment sets the alignment for a specific column

func (*Table) SetColumnColor

func (t *Table) SetColumnColor(columnIndex int, color *Color) *Table

SetColumnColor sets the color for a specific column

func (*Table) ShowBorders

func (t *Table) ShowBorders(show bool) *Table

ShowBorders controls whether to show borders

func (*Table) ShowHeader

func (t *Table) ShowHeader(show bool) *Table

ShowHeader controls whether to show the header row

func (*Table) WithBorderColor

func (t *Table) WithBorderColor(color *Color) *Table

WithBorderColor sets the border color

func (*Table) WithHeaderColor

func (t *Table) WithHeaderColor(color *Color) *Table

WithHeaderColor sets the header text color

func (*Table) WithMaxWidth

func (t *Table) WithMaxWidth(width int) *Table

WithMaxWidth sets the maximum table width

func (*Table) WithPadding

func (t *Table) WithPadding(padding int) *Table

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

func (t *Table) WithSmartWidth(percentage float64) *Table

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 TableStyle struct {
	TopLeft     string
	TopRight    string
	BottomLeft  string
	BottomRight string
	Horizontal  string
	Vertical    string
	Cross       string
	TopTee      string
	BottomTee   string
	LeftTee     string
	RightTee    string
}

type Terminal

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

func NewTerminal

func NewTerminal() *Terminal

NewTerminal creates a new terminal instance

func (*Terminal) Height

func (t *Terminal) Height() int

Height returns the terminal height

func (*Terminal) IsATTY

func (t *Terminal) IsATTY() bool

IsATTY returns true if stdout is a terminal

func (*Terminal) Width

func (t *Terminal) Width() int

Width returns the terminal width

type Theme added in v1.1.0

type Theme struct {
	Name       string
	Primary    *Color
	Secondary  *Color
	Success    *Color
	Warning    *Color
	Error      *Color
	Info       *Color
	Muted      *Color
	Background *Color
	Text       *Color
	Border     *Color
}

func GetTheme added in v1.1.0

func GetTheme() *Theme

GetTheme returns the current active theme

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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