output

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MPL-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package output prints results for people (a table) or for scripts (-o json), and turns the API's error codes into sentences.

Index

Constants

View Source
const (
	FormatTable = "table"
	FormatJson  = "json"
)

Variables

This section is empty.

Functions

func Explain

func Explain(problem *api.Problem) error

Explain is the error a command returns for an API answer that was not a success.

func Int

func Int(value *int32) string

func Number

func Number(value *json.Number) string

Number keeps every digit the API sent (money, prices): it is never parsed into a float.

func Text

func Text(value *string) string

func Time

func Time(value *time.Time) string

func ValidFormat

func ValidFormat(format string) error

func Word

func Word[T ~string](value *T) string

Word is an enum value of the API (a status, a state) as text.

Types

type Field

type Field struct {
	Name  string
	Value string
}

Field is one row of a single object printed as a table.

type Printer

type Printer struct {
	Format string
	Out    io.Writer
	Err    io.Writer
}

Printer writes results to Out and messages meant for the person at the terminal (prompts, warnings) to Err, so `-o json` output stays parseable.

func (*Printer) Message

func (p *Printer) Message(format string, args ...any)

Message is a line for the person at the terminal.

func (*Printer) Object

func (p *Printer) Object(fields []Field, value any) error

Object prints one object: as "Name: value" rows, or as value encoded to JSON.

func (*Printer) Table

func (p *Printer) Table(headers []string, rows [][]string, value any) error

Table prints a list: a header row and one row per item, or value encoded to JSON.

Jump to

Keyboard shortcuts

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