output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package output handles formatting and writing query results and errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrintError

func PrintError(qerr *agenterrors.QueryError)

PrintError writes a classified error to stderr as JSON.

func PrintJSON

func PrintJSON(data any, prune bool)

PrintJSON writes a JSON object to stdout (for admin/schema output).

func WriteError

func WriteError(w io.Writer, err error)

WriteError writes an error to stderr as JSON and sets the process exit code.

Types

type Format

type Format string

Format identifies an output format.

const (
	FormatNDJSON Format = "jsonl"
	FormatJSON   Format = "json"
	FormatYAML   Format = "yaml"
	FormatCSV    Format = "csv"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat parses a format string, returning an error for unknown formats.

type NDJSONWriter

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

NDJSONWriter writes query results as NDJSON (one JSON object per line).

func NewNDJSONWriter

func NewNDJSONWriter(w io.Writer) *NDJSONWriter

NewNDJSONWriter creates a new NDJSON result writer.

func (*NDJSONWriter) Flush

func (n *NDJSONWriter) Flush() error

func (*NDJSONWriter) WritePagination

func (n *NDJSONWriter) WritePagination(p *Pagination) error

func (*NDJSONWriter) WriteRow

func (n *NDJSONWriter) WriteRow(row map[string]any) error

type Pagination

type Pagination struct {
	HasMore  bool `json:"hasMore"`
	RowCount int  `json:"rowCount"`
}

Pagination holds pagination metadata for result sets.

type ResultWriter

type ResultWriter interface {
	WriteRow(row map[string]any) error
	WritePagination(p *Pagination) error
	Flush() error
}

ResultWriter writes query results in a streaming fashion.

Jump to

Keyboard shortcuts

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