output

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: MIT Imports: 8 Imported by: 0 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 formats a command result for display, per the freshbooks CLI's -o/--output flag: json, yaml, table, or name. See docs/cli.md for the user-facing description of each format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SortedKeys

func SortedKeys[V any](m map[string]V) []string

SortedKeys is a small helper for callers (config view) that want a stable key order over a map without going through the ordered-JSON path above.

func Write

func Write(w io.Writer, value any, opts Options) error

Write renders value to w per opts. value may be nil, a Go struct, a slice, a map, or a json.RawMessage -- anything json.Marshal accepts.

Types

type Format

type Format string

Format names one of the four supported output shapes.

const (
	JSON  Format = "json"
	YAML  Format = "yaml"
	Table Format = "table"
	Name  Format = "name"
)

The four output formats -o/--output accepts.

func DefaultFormat

func DefaultFormat(isTTY bool) Format

DefaultFormat is Table when stdout is a terminal, JSON otherwise -- the TTY-sensitive default -o/--output falls back to when unset by a flag, env var, or config file (see cli/internal/cmd for the precedence chain).

func (Format) Valid

func (f Format) Valid() bool

Valid reports whether f is one of the four supported formats.

type Options

type Options struct {
	// Format selects json, yaml, table, or name. The zero value is
	// treated as JSON.
	Format Format
	// NoHeaders suppresses the header row in table output. Ignored by
	// every other format.
	NoHeaders bool
}

Options controls how Format renders a value.

Jump to

Keyboard shortcuts

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