output

package
v0.2.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package output is the data layer's stdout-side sink. It takes a datasource.Source (which includes pipelines, since Pipeline satisfies Source) and writes its data to an io.Writer in JSON (one-shot polled sources) or NDJSON (streamed sources, one event per line).

Like internal/pipeline, this package MUST NOT import internal/screen, internal/build, or any tuilib package — the boundary that makes the wrangl binary TUI-free.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, src ds.Source, w io.Writer, opts Options) error

Run consumes from src and writes results to w. Decides between one-shot and streaming based on whether src implements StreamingSource AND its Subscribe doesn't return ErrNotStreaming. For one-shot, calls Fetch once and emits the result. For streaming, emits one frame per line until limits / cancellation.

Returns an error if Fetch/Subscribe failed. Honored ctx cancellation is NOT returned as an error — that's the clean shutdown path.

Types

type Options

type Options struct {
	// Pretty enables indented JSON output for one-shot mode. Streams
	// always emit one frame per line regardless (NDJSON is the contract
	// for line-oriented stream consumers like `jq -c`).
	Pretty bool
	// Raw bypasses JSON encoding for text values: string Fetch results
	// are written as-is (with a trailing newline), and streaming
	// Event.Line is written verbatim (no quote / escape). Non-string
	// Fetch results (parsed JSON) still go through json.Encode — there's
	// no raw text representation for those. Use --raw to make
	// `format: text` sources behave like `kubectl logs` or `tail -f`
	// for human reading.
	Raw bool
	// Limit caps the number of items emitted from a stream. 0 = no cap
	// (run until ctx is cancelled or the stream ends).
	Limit int
	// MaxDuration caps how long to consume from a stream. 0 = no cap.
	MaxDuration time.Duration
}

Options controls how a pipeline / source is dumped to a writer. Zero-value defaults: pretty JSON for one-shot, NDJSON for streams, no limit, no time cap.

Jump to

Keyboard shortcuts

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