display

package
v0.0.0-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 21, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckLessAvailable

func CheckLessAvailable() bool

CheckLessAvailable returns true if the less command is available

func GenerateDefaultCSVFilename

func GenerateDefaultCSVFilename() string

GenerateDefaultCSVFilename creates a default filename with timestamp

func GenerateFullTableContent

func GenerateFullTableContent(columnNames []string, allRows [][]interface{}, title string) string

GenerateFullTableContent creates complete formatted table content for paging

func GetTerminalSize

func GetTerminalSize() (width, height int)

GetTerminalSize returns both width and height of the terminal Returns (80, 24) as fallback if detection fails

func GetTerminalWidth

func GetTerminalWidth() int

GetTerminalWidth returns the current terminal width in characters Returns 80 as fallback if detection fails

func PageQueryResult

func PageQueryResult(data *QueryResultData, queryInfo string) error

PageQueryResult is a convenience function for paging query results

func PageResult

func PageResult(title string, content string) error

PageResult sends formatted table data to less for interactive viewing

func PageWithContext

func PageWithContext(ctx context.Context, title string, content string) error

PageWithContext is a context-aware version of PageResult

func SaveCSV

func SaveCSV(columnNames []string, allRows [][]interface{}, filename string) error

SaveCSV saves query results to a CSV file

func SaveQueryResultToCSV

func SaveQueryResultToCSV(columnNames []string, allRows [][]interface{}, filename string) (string, error)

SaveQueryResultToCSV is a convenience function for saving query results

Types

type ColumnInfo

type ColumnInfo struct {
	Name      string
	MaxWidth  int
	MinWidth  int
	IsNumeric bool
}

ColumnInfo represents information about a table column for formatting

type QueryResultData

type QueryResultData struct {
	ColumnNames []string
	Rows        [][]interface{}
	TotalRows   int
	Truncated   bool
}

QueryResultData represents the structure for query results (re-defined here to avoid import cycles)

type TableFormatter

type TableFormatter struct {
	// contains filtered or unexported fields
}

TableFormatter handles intelligent table formatting with dynamic column widths

func NewTableFormatter

func NewTableFormatter(columnNames []string) *TableFormatter

NewTableFormatter creates a new table formatter

func (*TableFormatter) AnalyzeData

func (tf *TableFormatter) AnalyzeData(sampleRows [][]interface{})

AnalyzeData analyzes sample data to determine optimal column characteristics

func (*TableFormatter) CalculateColumnWidths

func (tf *TableFormatter) CalculateColumnWidths() []int

CalculateColumnWidths determines optimal column widths based on terminal size

func (*TableFormatter) FormatHeader

func (tf *TableFormatter) FormatHeader(widths []int) string

FormatHeader creates the table header

func (*TableFormatter) FormatRow

func (tf *TableFormatter) FormatRow(row []interface{}, widths []int) string

FormatRow formats a single data row

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL