Documentation
¶
Index ¶
Constants ¶
const ( DefaultCSVDelimiter = "," DefaultTSVDelimiter = "\t" ValueKey = "value" )
const ( MaxColumnWidth = 60 // Maximum width for a column. TableColumnPadding = 3 // Padding for table columns. DefaultKeyWidth = 15 // Default base width for keys. KeyValue = "value" )
Constants for table formatting.
Variables ¶
var (
ErrTableTooWide = errors.New("the table is too wide to display properly")
)
Error variables for table formatting.
Functions ¶
func CreateStyledTable ¶ added in v1.176.0
createStyledTable creates a styled table with headers and rows.
func ValidateFormat ¶
ValidateFormat checks if the provided format is valid.
Types ¶
type DefaultFormatter ¶
type DefaultFormatter struct {
// contains filtered or unexported fields
}
DefaultFormatter provides a base implementation of Formatter.
type DelimitedFormatter ¶
type DelimitedFormatter struct {
DefaultFormatter
// contains filtered or unexported fields
}
DelimitedFormatter handles CSV and TSV format output.
func (*DelimitedFormatter) Format ¶
func (f *DelimitedFormatter) Format(data map[string]interface{}, options FormatOptions) (string, error)
Format implements the Formatter interface for DelimitedFormatter.
type FormatOptions ¶
type FormatOptions struct {
MaxColumns int
Delimiter string
TTY bool
Format Format
CustomHeaders []string
}
FormatOptions contains options for formatting output.
type Formatter ¶
type Formatter interface {
Format(data map[string]interface{}, options FormatOptions) (string, error)
}
Formatter defines the interface for formatting output.
func NewFormatter ¶
NewFormatter creates a new formatter for the specified format.
type JSONFormatter ¶
type JSONFormatter struct {
DefaultFormatter
}
JSONFormatter handles JSON format output.
func (*JSONFormatter) Format ¶
func (f *JSONFormatter) Format(data map[string]interface{}, options FormatOptions) (string, error)
Format implements the Formatter interface for JSONFormatter.
type TableFormatter ¶
type TableFormatter struct {
DefaultFormatter
}
TableFormatter handles table format output.
func (*TableFormatter) Format ¶
func (f *TableFormatter) Format(data map[string]interface{}, options FormatOptions) (string, error)
Format implements the Formatter interface for TableFormatter.
type YAMLFormatter ¶
type YAMLFormatter struct {
DefaultFormatter
}
YAMLFormatter handles YAML format output.
func (*YAMLFormatter) Format ¶
func (f *YAMLFormatter) Format(data map[string]interface{}, options FormatOptions) (string, error)
Format implements the Formatter interface for YAMLFormatter.