renderer

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 29, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DescribeTableResult

func DescribeTableResult(result pgxspecial.SpecialCommandResult, c *config.Config) (string, error)

DescribeTableResult renders each describe-table section.

func Error

func Error(err error, w io.Writer) error

Error writes the error message writer in red color.

func ExtensionVerboseResult

func ExtensionVerboseResult(result pgxspecial.SpecialCommandResult, c *config.Config) (string, error)

ExtensionVerboseResult renders each verbose extension result.

func FormatVal added in v0.2.1

func FormatVal(val driver.Value, showPrintableUnicode bool, showNewLinesAndTabs bool) string

FormatVal formats a value retrieved by a SQL driver into a string suitable for displaying to the user.

func GetColumnStrings added in v0.2.1

func GetColumnStrings(rows database.Rows, showMoreChars bool) []string

func GetTableStyle

func GetTableStyle(s *config.Config) renderer.ColorizedConfig

func Render added in v0.2.1

func Render(w, Ew io.Writer, formatter Formatter, cols []string, row RowStrIter) error

func RowsResult

func RowsResult(result pgxspecial.SpecialCommandResult, c *config.Config) (string, error)

RowsResult renders row-based special command output.

func Table

func Table(data Data, w io.Writer, c *config.Config) error

Table renders the provided data as a table. Currently been used by the special results / meta commands only.

func TableRender added in v0.2.1

func TableRender(cols []string, rowrowIter RowStrIter, caption string, w, Ew io.Writer, c *config.Config) error

Types

type ColorField

type ColorField string
const (
	ColorHeader  ColorField = "header"
	ColorColumn  ColorField = "column"
	ColorCaption ColorField = "caption"
)

type Data

type Data interface {
	Columns() []string
	Rows() ([][]any, error)
	Caption() string
}

type Formatter added in v0.2.1

type Formatter interface {
	Column(w io.Writer, cols []string) error
	Iter(w, Ew io.Writer, row []string) error
	Render(w io.Writer, seenRows int) error
	Done(w io.Writer) error
}

type RowIter added in v0.2.1

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

func NewRowIter added in v0.2.1

func NewRowIter(rows database.Rows, showMoreChars bool) *RowIter

func (*RowIter) Next added in v0.2.1

func (iter *RowIter) Next() (row []string, err error)

func (*RowIter) ToSlice added in v0.2.1

func (iter *RowIter) ToSlice() ([][]string, error)

type RowStrIter added in v0.2.1

type RowStrIter interface {
	Next() (row []string, err error)
	ToSlice() (allRows [][]string, err error)
}

RowStrIter is an iterator interface for the PrintQueryOutput function. It is used so that results can be streamed to the row formatters as they arrive to the CLI.

func NewRowSliceIter added in v0.2.1

func NewRowSliceIter(allRows [][]string) RowStrIter

NewRowSliceIter is an implementation of the rowStrIter interface and it is used when the rows have not been buffered into memory yet and we want to stream them to the row formatters as they arrive over the network.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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