output

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatText = "text"
	FormatJSON = "json"
)

Variables

This section is empty.

Functions

func AddFormatFlag

func AddFormatFlag(cmd *cobra.Command, defaultFormat string)

AddFormatFlag registers the -o/--output flag on cmd with the given default.

func DisplayResults

func DisplayResults(cmd *cobra.Command, resp *models.ResultsResponse) error

DisplayResults renders a ResultsResponse as JSON or table based on cmd flags.

func FormatBytes

func FormatBytes(b int64) string

FormatBytes returns a human-readable byte size string (e.g. "1.2 GB").

func FormatFromCmd

func FormatFromCmd(cmd *cobra.Command) string

FormatFromCmd reads the output flag value from cmd.

func PrintJSON

func PrintJSON(w io.Writer, v any) error

PrintJSON encodes v as indented JSON and writes it to w.

func PrintTable

func PrintTable(w io.Writer, columns []string, rows [][]string)

PrintTable writes columns and rows as aligned text using tabwriter.

func ResultRowsToStrings

func ResultRowsToStrings(rows []map[string]any, columns []string) [][]string

ResultRowsToStrings converts result rows to a string grid using column ordering.

Types

This section is empty.

Jump to

Keyboard shortcuts

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