printing

package
v3.0.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package printing is the tt core's side of github.com/tarantool/tt/sdk/output: it makes the Printer a command writes its result through, with the formats the SDK does not encode itself - YAML - and the terminal check that decides styling.

YAML goes through output.Normalize before it is encoded, as JSON does, so one result decodes to the same data whichever of the two a script asks for. YAML on its own could do more - spell NaN and the infinities as .nan and .inf, keep the integer key 1 apart from the string key "1" - and a result that relies on that would read differently in JSON; normalising both is what keeps -o json and -o yaml interchangeable. It also covers a struct with no exported fields that only has a String form, which YAML, like JSON, would write as {}.

The YAML library honours encoding.TextMarshaler, so a value that marshals itself as text is written as that text, as in JSON. A []byte is the one value the two formats still write differently: JSON carries it as base64, YAML as a sequence of integers.

Index

Constants

View Source
const FormatYAML = output.FormatYAML

FormatYAML is output.FormatYAML, the format this package encodes.

Variables

This section is empty.

Functions

func Formats

func Formats() []output.Format

Formats are the formats every result-printing tt command accepts, in the order the help text lists them.

func NewPrinter

func NewPrinter(format output.Format) (*output.Printer, error)

NewPrinter returns a Printer writing to the process's streams in format.

func Options

func Options() []output.Option

Options are the Printer options the core adds: the YAML encoders and the terminal probe.

Types

This section is empty.

Jump to

Keyboard shortcuts

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