Documentation
¶
Index ¶
- func CalcTableWidth(result *executor.QueryResult) int
- func CalcTableWidthWithMax(result *executor.QueryResult, maxWidth int) int
- func ExportResult(result *executor.QueryResult, path string, format ExportFormat) (int, error)
- func FormatValuePlain(v interface{}) string
- type ExportFormat
- type Format
- type Formatter
- func (f *Formatter) CurrentFormat() Format
- func (f *Formatter) MaxWidth() int
- func (f *Formatter) SetFormat(format Format)
- func (f *Formatter) SetMaxWidth(w int)
- func (f *Formatter) SetShowHeader(show bool)
- func (f *Formatter) SetShowTiming(show bool)
- func (f *Formatter) ShowHeader() bool
- func (f *Formatter) ShowTiming() bool
- func (f *Formatter) WriteResult(result *executor.QueryResult) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalcTableWidth ¶
func CalcTableWidth(result *executor.QueryResult) int
CalcTableWidth returns the display width (in runes) that a table-formatted result would require. Returns 0 if the result has no columns.
func CalcTableWidthWithMax ¶ added in v0.5.0
func CalcTableWidthWithMax(result *executor.QueryResult, maxWidth int) int
CalcTableWidthWithMax returns the display width after smart column truncation.
func ExportResult ¶
func ExportResult(result *executor.QueryResult, path string, format ExportFormat) (int, error)
ExportResult writes a query result to a file in the specified format. Returns the number of rows exported.
func FormatValuePlain ¶ added in v0.2.0
func FormatValuePlain(v interface{}) string
FormatValuePlain returns the plain text representation of a value (no ANSI codes). Exported for use by other packages (e.g., pipe output).
Types ¶
type ExportFormat ¶
type ExportFormat int
ExportFormat represents the file format for exporting query results.
const ( ExportCSV ExportFormat = iota ExportJSON ExportMarkdown )
func InferExportFormat ¶
func InferExportFormat(path string) (ExportFormat, error)
InferExportFormat infers the export format from a file extension.
func ParseExportFormat ¶
func ParseExportFormat(s string) (ExportFormat, error)
ParseExportFormat parses a format string and returns the ExportFormat.
func (ExportFormat) String ¶
func (f ExportFormat) String() string
String returns the string representation of an ExportFormat.
type Format ¶
type Format int
Format represents the output format type.
func ParseFormat ¶
ParseFormat parses a format string and returns the Format enum.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter formats and writes query results.
func NewFormatter ¶
NewFormatter creates a new Formatter with the given format and writer.
func (*Formatter) CurrentFormat ¶
CurrentFormat returns the current output format.
func (*Formatter) SetMaxWidth ¶ added in v0.5.0
SetMaxWidth sets the maximum terminal width for column truncation. A value of 0 means unlimited (no truncation).
func (*Formatter) SetShowHeader ¶ added in v0.6.6
SetShowHeader controls whether the column header row is displayed.
func (*Formatter) SetShowTiming ¶ added in v0.2.0
SetShowTiming controls whether execution time is displayed.
func (*Formatter) ShowHeader ¶ added in v0.6.6
ShowHeader returns whether the column header row is displayed.
func (*Formatter) ShowTiming ¶ added in v0.2.0
ShowTiming returns whether execution time display is enabled.
func (*Formatter) WriteResult ¶
func (f *Formatter) WriteResult(result *executor.QueryResult) error
WriteResult writes a QueryResult to the underlying writer using the current format.