Documentation ¶
Index ¶
- Variables
- func Bold(cmd *cobra.Command, s string)
- func BoldStr(s any) string
- func Elapsed(t time.Time) string
- func GreenStr(s any) string
- func Italic(cmd *cobra.Command, s string)
- func ItalicStr(s any) string
- func KeyValue(cmd *cobra.Command, data []collections.Pair[string, any])
- func Output[T any](cmd *cobra.Command, columns []TableColumn[T], options OutputOptions, items []T) error
- func OutputNonTabular[T any](cmd *cobra.Command, options NonTabularOutputOptions, items []T) error
- func OutputOne[T any](cmd *cobra.Command, columns []TableColumn[T], options OutputOptions, item T) error
- func OutputOneNonTabular[T any](cmd *cobra.Command, options NonTabularOutputOptions, item T) error
- func RedStr(s any) string
- func ShortenTime(formattedTime string, maxLen int) string
- func WrapSoftPreserveNewlines(s string, width int) string
- func YellowStr(s any) string
- type NonTabularOutputOptions
- type OutputFormat
- type OutputOptions
- type TableColumn
Constants ¶
This section is empty.
Variables ¶
View Source
var AllFormats = append([]OutputFormat{TableFormat, CSVFormat}, NonTabularFormats...)
View Source
var NonTabularFormats = []OutputFormat{JSONFormat, YAMLFormat}
Functions ¶
func Elapsed ¶ added in v1.2.2
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
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 WrapSoftPreserveNewlines ¶ added in v1.5.0
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 }
Click to show internal directories.
Click to hide internal directories.