Documentation
¶
Index ¶
- Constants
- Variables
- type Color
- type ColorLevel
- type List
- type ListItem
- type ListStyle
- type MultiSpinner
- type ProgressBar
- func (pb *ProgressBar) Add(n int)
- func (pb *ProgressBar) Finish()
- func (pb *ProgressBar) Increment()
- func (pb *ProgressBar) Set(current int)
- func (pb *ProgressBar) SetPrefix(prefix string) *ProgressBar
- func (pb *ProgressBar) SetStyle(style ProgressStyle) *ProgressBar
- func (pb *ProgressBar) SetSuffix(suffix string) *ProgressBar
- type ProgressStyle
- type Spinner
- func (s *Spinner) Fail(message string)
- func (s *Spinner) SetInterval(interval time.Duration) *Spinner
- func (s *Spinner) SetMessage(message string) *Spinner
- func (s *Spinner) SetStyle(style Style) *Spinner
- func (s *Spinner) Start() *Spinner
- func (s *Spinner) Stop()
- func (s *Spinner) Success(message string)
- func (s *Spinner) Warning(message string)
- type SpinnerLine
- type Style
- type Table
- type TableStyle
- type Terminal
- func (t *Terminal) Banner(title string, width int)
- func (t *Terminal) ClearLine()
- func (t *Terminal) ColorLevel() ColorLevel
- func (t *Terminal) Divider(char string, color Color)
- func (t *Terminal) DrawBox(width, height int, title string)
- func (t *Terminal) Error(text string)
- func (t *Terminal) ErrorMsg(message string)
- func (t *Terminal) Errorf(format string, args ...interface{})
- func (t *Terminal) Errorln(text string)
- func (t *Terminal) Height() int
- func (t *Terminal) HideCursor()
- func (t *Terminal) Hyperlink(text, url string) string
- func (t *Terminal) Info(message string)
- func (t *Terminal) IsTTY() bool
- func (t *Terminal) KeyValue(key, value string, keyWidth int)
- func (t *Terminal) MoveCursor(line, col int)
- func (t *Terminal) NewList() *List
- func (t *Terminal) NewMultiSpinner() *MultiSpinner
- func (t *Terminal) NewProgressBar(total int) *ProgressBar
- func (t *Terminal) NewSpinner(frames []string) *Spinner
- func (t *Terminal) NewTable(headers []string) *Table
- func (t *Terminal) Print(text string)
- func (t *Terminal) PrintHyperlink(text, url string, style Style)
- func (t *Terminal) PrintStyled(text string, style Style)
- func (t *Terminal) Printf(format string, args ...interface{})
- func (t *Terminal) Println(text string)
- func (t *Terminal) PrintlnStyled(text string, style Style)
- func (t *Terminal) RestoreCursor()
- func (t *Terminal) SaveCursor()
- func (t *Terminal) Section(title string)
- func (t *Terminal) ShowCursor()
- func (t *Terminal) Success(message string)
- func (t *Terminal) Truncate(text string, maxWidth int) string
- func (t *Terminal) Warning(message string)
- func (t *Terminal) Width() int
- func (t *Terminal) Wrap(text string, width int) []string
Constants ¶
const ( BoxTopLeft = "┌" BoxTopRight = "┐" BoxBottomLeft = "└" BoxBottomRight = "┘" BoxHorizontal = "─" BoxVertical = "│" BoxTeeLeft = "├" BoxTeeRight = "┤" BoxTeeTop = "┬" BoxTeeBottom = "┴" BoxCross = "┼" )
Box characters for drawing
Variables ¶
var ( // DefaultTableStyle is the default table style DefaultTableStyle = TableStyle{ HeaderColor: ColorCyan, BorderColor: ColorBrightBlack, ShowBorder: true, Compact: false, } // CompactTableStyle is a compact table style CompactTableStyle = TableStyle{ HeaderColor: ColorCyan, BorderColor: ColorBrightBlack, ShowBorder: false, Compact: true, } )
var ( // DefaultListStyle is the default list style DefaultListStyle = ListStyle{ BulletColor: ColorCyan, Indent: 2, Bullets: []string{"•", "◦", "▸", "‣"}, } // NumberedListStyle uses numbers NumberedListStyle = ListStyle{ BulletColor: ColorCyan, Indent: 2, Bullets: []string{"%d.", "%d)", "%d."}, } )
var ( // DefaultProgressStyle is the default progress bar style DefaultProgressStyle = ProgressStyle{ FilledChar: "█", EmptyChar: "░", LeftBracket: "[", RightBracket: "]", Color: ColorCyan, } // GradientProgressStyle uses gradient colors GradientProgressStyle = ProgressStyle{ FilledChar: "█", EmptyChar: "░", LeftBracket: "[", RightBracket: "]", Color: ColorSuccess, } // ArrowProgressStyle uses arrows ArrowProgressStyle = ProgressStyle{ FilledChar: "▶", EmptyChar: "▷", LeftBracket: "⟨", RightBracket: "⟩", Color: ColorBlue, } )
var ( // SpinnerDots is a simple dots spinner SpinnerDots = []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"} // SpinnerLineFrames is a line spinner SpinnerLineFrames = []string{"-", "\\", "|", "/"} // SpinnerArrow is an arrow spinner SpinnerArrow = []string{"←", "↖", "↑", "↗", "→", "↘", "↓", "↙"} // SpinnerCircle is a circle spinner SpinnerCircle = []string{"◐", "◓", "◑", "◒"} // SpinnerGrowth is a growing spinner SpinnerGrowth = []string{"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█", "▇", "▆", "▅", "▄", "▃", "▂"} // SpinnerBounce is a bouncing spinner SpinnerBounce = []string{"⠁", "⠂", "⠄", "⡀", "⢀", "⠠", "⠐", "⠈"} )
var ( // Standard ANSI colors ColorBlack = Color{Code: 30} ColorRed = Color{Code: 31} ColorGreen = Color{Code: 32} ColorYellow = Color{Code: 33} ColorBlue = Color{Code: 34} ColorMagenta = Color{Code: 35} ColorCyan = Color{Code: 36} ColorWhite = Color{Code: 37} // Bright colors ColorBrightBlack = Color{Code: 90} ColorBrightRed = Color{Code: 91} ColorBrightGreen = Color{Code: 92} ColorBrightYellow = Color{Code: 93} ColorBrightBlue = Color{Code: 94} ColorBrightMagenta = Color{Code: 95} ColorBrightCyan = Color{Code: 96} ColorBrightWhite = Color{Code: 97} // Presets for common use cases ColorCritical = Color{R: 220, G: 38, B: 38, IsRGB: true} // Bright red ColorHigh = Color{R: 251, G: 191, B: 36, IsRGB: true} // Orange/Yellow ColorMedium = Color{R: 251, G: 146, B: 60, IsRGB: true} // Orange ColorLow = Color{R: 59, G: 130, B: 246, IsRGB: true} // Blue ColorInfo = Color{R: 99, G: 102, B: 241, IsRGB: true} // Indigo ColorSuccess = Color{R: 34, G: 197, B: 94, IsRGB: true} // Green ColorWarning = Color{R: 234, G: 179, B: 8, IsRGB: true} // Amber ColorError = Color{R: 239, G: 68, B: 68, IsRGB: true} // Red )
Functions ¶
This section is empty.
Types ¶
type ColorLevel ¶
type ColorLevel int
ColorLevel represents the terminal's color capability
const ( // ColorLevelNone represents no color support ColorLevelNone ColorLevel = iota // ColorLevelBasic represents 16-color support ColorLevelBasic // ColorLevel256 represents 256-color support ColorLevel256 // ColorLevelTrueColor represents 24-bit true color support ColorLevelTrueColor )
type List ¶
type List struct {
// contains filtered or unexported fields
}
List represents a formatted list
func (*List) AddColored ¶
AddColored adds a colored item to the list
func (*List) AddWithLevel ¶
AddWithLevel adds an item with a specific indentation level
type ListStyle ¶
type ListStyle struct {
BulletColor Color
Indent int
Bullets []string // Bullets for different levels
}
ListStyle defines the visual style of the list
type MultiSpinner ¶
type MultiSpinner struct {
// contains filtered or unexported fields
}
MultiSpinner manages multiple concurrent spinners
func (*MultiSpinner) Add ¶
func (ms *MultiSpinner) Add(key, message string)
Add adds a new spinner line
func (*MultiSpinner) Fail ¶
func (ms *MultiSpinner) Fail(key, message string)
Fail marks a spinner as failed
func (*MultiSpinner) Success ¶
func (ms *MultiSpinner) Success(key, message string)
Success marks a spinner as successful
func (*MultiSpinner) Update ¶
func (ms *MultiSpinner) Update(key, message string)
Update updates a spinner line's message
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
ProgressBar represents a progress indicator
func (*ProgressBar) Increment ¶
func (pb *ProgressBar) Increment()
Increment increments the progress by one
func (*ProgressBar) SetPrefix ¶
func (pb *ProgressBar) SetPrefix(prefix string) *ProgressBar
SetPrefix sets the prefix text
func (*ProgressBar) SetStyle ¶
func (pb *ProgressBar) SetStyle(style ProgressStyle) *ProgressBar
SetStyle sets the progress bar style
func (*ProgressBar) SetSuffix ¶
func (pb *ProgressBar) SetSuffix(suffix string) *ProgressBar
SetSuffix sets the suffix text
type ProgressStyle ¶
type ProgressStyle struct {
FilledChar string
EmptyChar string
LeftBracket string
RightBracket string
Color Color
}
ProgressStyle defines the visual style of the progress bar
type Spinner ¶
type Spinner struct {
// contains filtered or unexported fields
}
Spinner represents an animated spinner
func (*Spinner) SetInterval ¶
SetInterval sets the animation interval
func (*Spinner) SetMessage ¶
SetMessage sets the spinner message
type SpinnerLine ¶
type SpinnerLine struct {
// contains filtered or unexported fields
}
SpinnerLine represents a single line in a multi-spinner
type Style ¶
type Style struct {
Foreground Color
Background Color
Bold bool
Italic bool
Underline bool
Dim bool
Blink bool
Reverse bool
Hidden bool
Strike bool
}
Style represents text styling options
func (Style) WithBackground ¶
WithBackground sets the background color
func (Style) WithForeground ¶
WithForeground sets the foreground color
func (Style) WithUnderline ¶
WithUnderline enables underlined text
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a formatted table
func (*Table) SetStyle ¶
func (tbl *Table) SetStyle(style TableStyle) *Table
SetStyle sets the table style
type TableStyle ¶
TableStyle defines the visual style of the table
type Terminal ¶
type Terminal struct {
// contains filtered or unexported fields
}
Terminal provides intelligent terminal output capabilities
func (*Terminal) ColorLevel ¶
func (t *Terminal) ColorLevel() ColorLevel
ColorLevel returns the terminal's color capability
func (*Terminal) Hyperlink ¶
Hyperlink creates a clickable terminal hyperlink (if supported) Falls back to just showing the URL if hyperlinks aren't supported
func (*Terminal) MoveCursor ¶
MoveCursor moves the cursor to the specified position
func (*Terminal) NewMultiSpinner ¶
func (t *Terminal) NewMultiSpinner() *MultiSpinner
NewMultiSpinner creates a new multi-spinner
func (*Terminal) NewProgressBar ¶
func (t *Terminal) NewProgressBar(total int) *ProgressBar
NewProgressBar creates a new progress bar
func (*Terminal) NewSpinner ¶
NewSpinner creates a new spinner
func (*Terminal) PrintHyperlink ¶
PrintHyperlink prints a clickable hyperlink
func (*Terminal) PrintStyled ¶
PrintStyled writes styled text to the terminal
func (*Terminal) PrintlnStyled ¶
PrintlnStyled writes styled text with a newline to the terminal
func (*Terminal) RestoreCursor ¶
func (t *Terminal) RestoreCursor()
RestoreCursor restores the saved cursor position
func (*Terminal) SaveCursor ¶
func (t *Terminal) SaveCursor()
SaveCursor saves the current cursor position