clioutputwriter

package
v0.0.0-...-ff94329 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedFormat = fmt.Errorf("unsupported output format")
)

Functions

func PrintData

func PrintData(w io.Writer, data TabularData, format Format) error

PrintData is the main function to print data in the specified format.

func SupportedOutputFormats

func SupportedOutputFormats() []string

SupportedOutputFormats returns the list of supported output formats, for use in help text.

Types

type Format

type Format string

Format represents the output format.

const (
	FormatTable   Format = "table"
	FormatJSON    Format = "json"
	FormatCSV     Format = "csv"
	FormatNuShell Format = "nushell"
)

func DefaultOutputFormat

func DefaultOutputFormat() Format

DefaultOutputFormat returns the suggested output format

type TabularData

type TabularData struct {
	Headers []string        // Column headers
	Rows    [][]interface{} // Rows of data
}

TabularData represents the data to be printed in a structured format.

func FilterColumns

func FilterColumns(data TabularData, columns []string) TabularData

FilterColumns will filter out all columns not in the provided list.

Jump to

Keyboard shortcuts

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