Documentation
¶
Overview ¶
Package output provides output formatting for CLI applications. Handles table output, JSON formatting, color detection, and terminal width.
Example usage:
formatter := output.New("table", "auto", false)
tbl := formatter.NewTable("Name", "Value")
tbl.AddRow("item1", "data1").AddRow("item2", "data2")
tbl.Print()
Index ¶
- func IsTerminal() bool
- func PrintBanner(title string)
- func PrintEmptyMessage(itemType string)
- func PrintError(format string, args ...interface{})
- func PrintSuccess(format string, args ...interface{})
- func PrintWarning(format string, args ...interface{})
- func TruncateString(s string, max int) string
- func ValidateFormat(format string) error
- type Formatter
- type TableBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func PrintBanner ¶
func PrintBanner(title string)
PrintBanner prints a standard banner (for update notifications, etc.)
func PrintEmptyMessage ¶
func PrintEmptyMessage(itemType string)
PrintEmptyMessage prints a standard "No X found" message
func PrintError ¶
func PrintError(format string, args ...interface{})
PrintError prints a standard error message
func PrintSuccess ¶
func PrintSuccess(format string, args ...interface{})
PrintSuccess prints a standard success message
func PrintWarning ¶
func PrintWarning(format string, args ...interface{})
PrintWarning prints a standard warning message
func TruncateString ¶
TruncateString truncates a string to max length with ellipsis
func ValidateFormat ¶
ValidateFormat checks if the format is supported
Types ¶
type Formatter ¶
Formatter handles output formatting
func (*Formatter) NewTable ¶
func (f *Formatter) NewTable(headers ...string) *TableBuilder
NewTable creates a new table builder
type TableBuilder ¶
type TableBuilder struct {
// contains filtered or unexported fields
}
TableBuilder helps construct tables with consistent formatting
func (*TableBuilder) AddRow ¶
func (tb *TableBuilder) AddRow(row ...interface{}) *TableBuilder
AddRow adds a row to the table
func (*TableBuilder) Print ¶
func (tb *TableBuilder) Print()
Print outputs the table (or raw data if NoHeaders without color)
func (*TableBuilder) PrintWithFallback ¶
func (tb *TableBuilder) PrintWithFallback(printRaw func())
PrintWithFallback prints with fallback to raw output