output

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package output provides structured output formatting for CLI commands. It supports text (default) and JSON output modes, allowing commands to produce machine-readable output for CI/CD pipelines and scripting.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Format

type Format string

Format represents the output format for commands.

const (
	// FormatText is the default human-readable output format.
	FormatText Format = "text"
	// FormatJSON produces machine-readable JSON output.
	FormatJSON Format = "json"
)

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

Writer handles formatted output based on the configured format.

func NewWriter

func NewWriter(w io.Writer, format Format) *Writer

NewWriter creates an output writer for the given format.

func (*Writer) IsJSON

func (o *Writer) IsJSON() bool

IsJSON returns true if the writer is configured for JSON output.

func (*Writer) Write

func (o *Writer) Write(data any, textFunc func(io.Writer)) error

Write outputs data in the configured format. For JSON format, data is marshalled to indented JSON. For text format, the textFunc is called to produce human-readable output.

Jump to

Keyboard shortcuts

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