Documentation
¶
Overview ¶
Package pretty provides consistent, professional CLI output formatting using lipgloss.
Index ¶
- func Accent(s string) string
- func AlignCenter(s string, width int) string
- func AlignLeft(s string, width int) string
- func AlignRight(s string, width int) string
- func Bold(s string) string
- func Box(content string, title string) string
- func Dim(s string) string
- func Error(s string) string
- func GetTerminalHeight() int
- func GetTerminalWidth() int
- func Indent(s string, spaces int) string
- func Info(s string) string
- func IsInteractive() bool
- func ShouldUseColor() bool
- func Success(s string) string
- func Truncate(s string, maxLen int) string
- func Underline(s string) string
- func Warning(s string) string
- func WrapText(s string, width int) string
- type ListConfig
- type ListStyle
- type ListWriter
- type Pager
- type PagerConfig
- type ProgressConfig
- type ProgressTracker
- func (pt *ProgressTracker) Increment(id string)
- func (pt *ProgressTracker) IsActive() bool
- func (pt *ProgressTracker) MarkDone(id string)
- func (pt *ProgressTracker) MarkError(id string)
- func (pt *ProgressTracker) Start()
- func (pt *ProgressTracker) Stop()
- func (pt *ProgressTracker) Track(id, message string, total int64)
- func (pt *ProgressTracker) Update(id string, current int64)
- func (pt *ProgressTracker) UpdateMessage(id, message string)
- type TableConfig
- type TableStyle
- type TableWriter
- func (w *TableWriter) AppendRow(row ...interface{})
- func (w *TableWriter) AppendRows(rows [][]interface{})
- func (w *TableWriter) AppendSeparator()
- func (w *TableWriter) Render(out io.Writer)
- func (w *TableWriter) RenderString() string
- func (w *TableWriter) SetAutoIndex(enabled bool)
- func (w *TableWriter) SetColumnConfig(columnNumber int, config interface{})
- func (w *TableWriter) SetHeader(headers ...interface{})
- func (w *TableWriter) SortBy(columnNumber int, ascending bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlignCenter ¶
AlignCenter centers string within width.
func AlignRight ¶
AlignRight pads string to width with spaces on the left.
func GetTerminalHeight ¶
func GetTerminalHeight() int
GetTerminalHeight returns the height of the terminal.
func GetTerminalWidth ¶
func GetTerminalWidth() int
GetTerminalWidth returns the width of the terminal.
func IsInteractive ¶
func IsInteractive() bool
IsInteractive returns true if the output is an interactive terminal.
func ShouldUseColor ¶
func ShouldUseColor() bool
ShouldUseColor determines if color output should be enabled.
Types ¶
type ListConfig ¶
type ListConfig struct {
// ColorEnabled controls whether to use colors in output.
ColorEnabled bool
// Indent is the number of spaces per indentation level.
Indent int
}
ListConfig holds configuration for list rendering.
func DefaultListConfig ¶
func DefaultListConfig() ListConfig
DefaultListConfig returns sensible defaults for list rendering.
type ListWriter ¶
type ListWriter struct {
// contains filtered or unexported fields
}
ListWriter provides list rendering with lipgloss styling.
func NewListWriter ¶
func NewListWriter(style ListStyle, config ListConfig) *ListWriter
NewListWriter creates a new list writer with the given style and config.
func (*ListWriter) AppendItem ¶
func (w *ListWriter) AppendItem(item interface{})
AppendItem adds an item to the list.
func (*ListWriter) AppendItems ¶
func (w *ListWriter) AppendItems(items []interface{})
AppendItems adds multiple items to the list.
func (*ListWriter) Indent ¶
func (w *ListWriter) Indent()
Indent increases the indentation level for subsequent items.
func (*ListWriter) Render ¶
func (w *ListWriter) Render(out io.Writer)
Render outputs the list to the given writer.
func (*ListWriter) RenderString ¶
func (w *ListWriter) RenderString() string
RenderString returns the list as a string.
func (*ListWriter) UnIndent ¶
func (w *ListWriter) UnIndent()
UnIndent decreases the indentation level.
type Pager ¶
type Pager struct {
// contains filtered or unexported fields
}
Pager handles paginated output for long content.
func NewPager ¶
func NewPager(config PagerConfig) *Pager
NewPager creates a new pager with the given configuration.
type PagerConfig ¶
type PagerConfig struct {
// PageSize is the number of lines per page (0 = auto-detect from terminal height)
PageSize int
// Output is where paginated content is written
Output io.Writer
}
PagerConfig holds configuration for the pager.
func DefaultPagerConfig ¶
func DefaultPagerConfig() PagerConfig
DefaultPagerConfig returns sensible defaults for pagination.
type ProgressConfig ¶
type ProgressConfig struct {
// Enabled controls whether progress is shown
Enabled bool
// Output is where progress is written (usually os.Stderr)
Output io.Writer
// UpdateFrequency controls how often progress updates
UpdateFrequency time.Duration
}
ProgressConfig holds configuration for progress tracking.
func DefaultProgressConfig ¶
func DefaultProgressConfig() ProgressConfig
DefaultProgressConfig returns sensible defaults for progress tracking.
type ProgressTracker ¶
type ProgressTracker struct {
// contains filtered or unexported fields
}
ProgressTracker manages multiple progress indicators using lipgloss.
func NewProgressTracker ¶
func NewProgressTracker(config ProgressConfig) *ProgressTracker
NewProgressTracker creates a new progress tracker.
func (*ProgressTracker) Increment ¶
func (pt *ProgressTracker) Increment(id string)
Increment increments the progress for a specific tracker.
func (*ProgressTracker) IsActive ¶
func (pt *ProgressTracker) IsActive() bool
IsActive returns whether the tracker is currently active.
func (*ProgressTracker) MarkDone ¶
func (pt *ProgressTracker) MarkDone(id string)
MarkDone marks a tracker as complete.
func (*ProgressTracker) MarkError ¶
func (pt *ProgressTracker) MarkError(id string)
MarkError marks a tracker as failed.
func (*ProgressTracker) Track ¶
func (pt *ProgressTracker) Track(id, message string, total int64)
Track adds a new progress tracker with the given ID and message.
func (*ProgressTracker) Update ¶
func (pt *ProgressTracker) Update(id string, current int64)
Update updates the progress for a specific tracker.
func (*ProgressTracker) UpdateMessage ¶
func (pt *ProgressTracker) UpdateMessage(id, message string)
UpdateMessage updates the message for a specific tracker.
type TableConfig ¶
type TableConfig struct {
// MaxWidth is the maximum table width (0 = auto-detect from terminal).
MaxWidth int
// ColorEnabled controls whether to use colors in output.
ColorEnabled bool
// AutoWrap enables automatic text wrapping in columns.
AutoWrap bool
// SortColumn is the column index to sort by (-1 = no sorting).
SortColumn int
// SortAsc controls sort direction (true = ascending).
SortAsc bool
}
TableConfig holds configuration for table rendering.
func DefaultTableConfig ¶
func DefaultTableConfig() TableConfig
DefaultTableConfig returns sensible defaults for table rendering.
type TableStyle ¶
type TableStyle int
TableStyle defines the visual style for tables.
const ( // StyleBordered uses rounded borders with full table structure. StyleBordered TableStyle = iota // StyleLight uses light borders for a clean look. StyleLight // StyleMinimal uses no borders, just spacing (default). StyleMinimal // StyleCompact uses dense formatting for large datasets. StyleCompact )
type TableWriter ¶
type TableWriter struct {
// contains filtered or unexported fields
}
TableWriter provides table rendering with lipgloss styling.
func NewTableWriter ¶
func NewTableWriter(style TableStyle, config TableConfig) *TableWriter
NewTableWriter creates a new table writer with the given style and config.
func (*TableWriter) AppendRow ¶
func (w *TableWriter) AppendRow(row ...interface{})
AppendRow adds a data row to the table.
func (*TableWriter) AppendRows ¶
func (w *TableWriter) AppendRows(rows [][]interface{})
AppendRows adds multiple data rows.
func (*TableWriter) AppendSeparator ¶
func (w *TableWriter) AppendSeparator()
AppendSeparator adds a visual separator line (no-op for lipgloss implementation).
func (*TableWriter) Render ¶
func (w *TableWriter) Render(out io.Writer)
Render outputs the table to the given writer.
func (*TableWriter) RenderString ¶
func (w *TableWriter) RenderString() string
RenderString returns the rendered table as a string.
func (*TableWriter) SetAutoIndex ¶
func (w *TableWriter) SetAutoIndex(enabled bool)
SetAutoIndex enables row numbering (no-op for lipgloss implementation).
func (*TableWriter) SetColumnConfig ¶
func (w *TableWriter) SetColumnConfig(columnNumber int, config interface{})
SetColumnConfig sets configuration for a specific column (no-op for lipgloss implementation).
func (*TableWriter) SetHeader ¶
func (w *TableWriter) SetHeader(headers ...interface{})
SetHeader sets the table header row.
func (*TableWriter) SortBy ¶
func (w *TableWriter) SortBy(columnNumber int, ascending bool)
SortBy sorts the table by the configured column (no-op for lipgloss implementation).