output

package
v1.3.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NonTabularFormats = []OutputFormat{JSONFormat, YAMLFormat}

Functions

func Bold added in v1.2.2

func Bold(cmd *cobra.Command, s string)

Bold prints the given string in bold

func Elapsed added in v1.2.2

func Elapsed(t time.Time) string

Elapsed returns a human-readable string representing the time elapsed since t e.g. "3d" for 3 days, "2h" for 2 hours, "5m" for 5 minutes, "10s" for 10 seconds

func KeyValue added in v1.2.2

func KeyValue(cmd *cobra.Command, data []collections.Pair[string, any])

KeyValue prints a list of key-value pairs in a human-readable format with the keys aligned. Example:

KeyValue(cmd, []collections.Pair[string, any]{
  collections.NewPair("Name", "John"),
  collections.NewPair("Age", 30),
})

Output:

Name = John
Age  = 30

func Output

func Output[T any](cmd *cobra.Command, columns []TableColumn[T], options OutputOptions, items []T) error

func OutputNonTabular added in v1.1.0

func OutputNonTabular[T any](cmd *cobra.Command, options NonTabularOutputOptions, items []T) error

func OutputOne

func OutputOne[T any](cmd *cobra.Command, columns []TableColumn[T], options OutputOptions, item T) error

func OutputOneNonTabular added in v1.1.0

func OutputOneNonTabular[T any](cmd *cobra.Command, options NonTabularOutputOptions, item T) error

func ShortenTime added in v1.1.0

func ShortenTime(formattedTime string, maxLen int) string

Types

type NonTabularOutputOptions added in v1.1.0

type NonTabularOutputOptions struct {
	Format OutputFormat // The output format for the list of jobs
	Pretty bool         // Pretty print the output
}

type OutputFormat

type OutputFormat string
const (
	TableFormat OutputFormat = "table"
	CSVFormat   OutputFormat = "csv"
	JSONFormat  OutputFormat = "json"
	YAMLFormat  OutputFormat = "yaml"
)

type OutputOptions

type OutputOptions struct {
	Format     OutputFormat // The output format for the list of jobs
	Pretty     bool         // Pretty print the output
	HideHeader bool         // Hide the column headers
	NoStyle    bool         // Remove all styling from table output.
	Wide       bool         // Print full values in the table results
	SortBy     []table.SortBy
}

type TableColumn

type TableColumn[T any] struct {
	table.ColumnConfig
	Value func(T) string
}

Jump to

Keyboard shortcuts

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