format

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package format renders query results as CSV, TSV, or JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Write

func Write(w io.Writer, f Format, result *redash.QueryResult) error

Write renders the result in the given format. Rows arrive as maps keyed by column name, so CSV/TSV column order is taken from result.Columns.

func WriteObject

func WriteObject(w io.Writer, v any) error

WriteObject renders one value as JSON, for output that is a single record rather than the row set Write renders — the saved query `rdsh query show` reads. Both go through here so that every JSON stream rdsh prints is spelled one way rather than by coincidence between two call sites.

Types

type Format

type Format string

Format is an output format accepted by Write. It implements pflag.Value, so a --format typo is rejected while cobra parses the flags — before the command runs and submits the query to the server.

const (
	CSV  Format = "csv"
	TSV  Format = "tsv"
	JSON Format = "json"
)

Formats accepted by Write.

func (*Format) Set

func (f *Format) Set(s string) error

Set implements pflag.Value.

func (Format) String

func (f Format) String() string

func (Format) Type

func (Format) Type() string

Type names the value shown in the --format help line. It reports "string" rather than "format" because that help text is part of the agent-facing contract; see the documentation sync rule in CLAUDE.md.

Jump to

Keyboard shortcuts

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