Documentation
¶
Index ¶
Constants ¶
const ColSpacing = 2
ColSpacing is the number of spaces between columns.
Variables ¶
This section is empty.
Functions ¶
func DisplayBytes ¶
DisplayBytes converts an integer value to a string in bytes, kilobytes, megabytes, or gigabytes
func DisplayDateTime ¶
DisplayDateTime converts a time.Time value to a string in time.Stamp format
func DisplayDuration ¶
DisplayDuration calculates the duration between two time.Time values and returns a string
Types ¶
type FieldDefinition ¶
type FieldDefinition struct {
Name string
Width int
Type FieldType
Format string // Used for time formatting
DisplayFunc func(row map[string]interface{}, name string) string
}
FieldDefinition represents a field in a table.
type Table ¶
type Table struct {
// contains filtered or unexported fields
}
Table represents a table with fields and data.
func NewTable ¶
func NewTable(fields []FieldDefinition, colorFunc func(map[string]interface{}) string) *Table
NewTable creates a new table with the specified fields and color function. The color function is used to color rows based on their content, it should return an ANSI color code.
func (*Table) DisplayJSON ¶
DisplayJSON outputs the table's data as an indented JSON string.
func (*Table) DisplayTable ¶
DisplayTable displays a JSON array as a table, trimming rows to fit terminal width.
func (*Table) ParseJsonData ¶
Parse processes the data to conform to field definitions. The data should be a slice of maps where each map represents a row.