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 WriteError ¶
WriteError writes an error to stderr as JSON and sets the process exit code.
Types ¶
type CSVWriter ¶ added in v1.1.0
type CSVWriter struct {
// contains filtered or unexported fields
}
CSVWriter streams rows as CSV. Column order is fixed at construction.
func NewCSVWriter ¶ added in v1.1.0
NewCSVWriter creates a new CSV writer with the given column order.
func (*CSVWriter) WritePagination ¶ added in v1.1.0
func (c *CSVWriter) WritePagination(_ *Pagination) error
WritePagination is a no-op for CSV — no metadata support.
type Format ¶
type Format string
Format identifies an output format.
func ParseFormat ¶
ParseFormat parses a format string, returning an error for unknown formats.
func ResolveFormat ¶ added in v1.1.0
ResolveFormat resolves the output format from flag > config > default.
type JSONWriter ¶ added in v1.1.0
type JSONWriter struct {
// contains filtered or unexported fields
}
JSONWriter buffers all rows and writes a single JSON envelope on Flush.
func NewJSONWriter ¶ added in v1.1.0
func NewJSONWriter(w io.Writer, columns []string) *JSONWriter
NewJSONWriter creates a new JSON envelope writer. If columns is non-nil, it defines the column order; otherwise columns are extracted from the first row.
func (*JSONWriter) Flush ¶ added in v1.1.0
func (j *JSONWriter) Flush() error
func (*JSONWriter) WritePagination ¶ added in v1.1.0
func (j *JSONWriter) WritePagination(p *Pagination) error
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
type Pagination ¶
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.
type YAMLWriter ¶ added in v1.1.0
type YAMLWriter struct {
// contains filtered or unexported fields
}
YAMLWriter buffers all rows and writes YAML on Flush.
func NewYAMLWriter ¶ added in v1.1.0
func NewYAMLWriter(w io.Writer, columns []string) *YAMLWriter
NewYAMLWriter creates a new YAML writer. If columns is non-nil, it defines the column order; otherwise columns are extracted from the first row.
func (*YAMLWriter) Flush ¶ added in v1.1.0
func (y *YAMLWriter) Flush() error
func (*YAMLWriter) WritePagination ¶ added in v1.1.0
func (y *YAMLWriter) WritePagination(p *Pagination) error