Documentation ¶
Index ¶
- Variables
- func Completions[T any](values []T, fields map[string]func(T) string, opts ...Options) (results []string)
- func Details[T any](value T, fields map[string]func(T) string, opts ...Options) string
- func FormatSmallID(id string) string
- func Table[T any](values []T, fields map[string]func(T) string, opts ...Options) *table.Table
- type Options
Constants ¶
This section is empty.
Variables ¶
var ( AIMSDefault = table.Style{ Name: "AIMSDefault", Box: table.BoxStyle{ BottomLeft: " ", BottomRight: " ", BottomSeparator: " ", Left: " ", LeftSeparator: " ", MiddleHorizontal: "=", MiddleSeparator: " ", MiddleVertical: " ", PaddingLeft: " ", PaddingRight: " ", Right: " ", RightSeparator: " ", TopLeft: " ", TopRight: " ", TopSeparator: " ", UnfinishedRow: "~~", }, Color: table.ColorOptions{ IndexColumn: text.Colors{}, Footer: text.Colors{}, Header: text.Colors{}, Row: text.Colors{}, RowAlternate: text.Colors{}, }, Format: table.FormatOptions{ Footer: text.FormatDefault, Header: text.FormatTitle, Row: text.FormatDefault, }, Options: table.Options{ DrawBorder: false, SeparateColumns: true, SeparateFooter: false, SeparateHeader: true, SeparateRows: false, }, } AIMSBordersDefault = table.Style{ Name: "AIMSBordersDefault", Box: table.BoxStyle{ BottomLeft: "+", BottomRight: "+", BottomSeparator: "-", Left: "|", LeftSeparator: "+", MiddleHorizontal: "-", MiddleSeparator: "+", MiddleVertical: "|", PaddingLeft: " ", PaddingRight: " ", Right: "|", RightSeparator: "+", TopLeft: "+", TopRight: "+", TopSeparator: "-", UnfinishedRow: "~~", }, Color: table.ColorOptions{ IndexColumn: text.Colors{}, Footer: text.Colors{}, Header: text.Colors{}, Row: text.Colors{}, RowAlternate: text.Colors{}, }, Format: table.FormatOptions{ Footer: text.FormatDefault, Header: text.FormatTitle, Row: text.FormatDefault, }, Options: table.Options{ DrawBorder: true, SeparateColumns: true, SeparateFooter: false, SeparateHeader: true, SeparateRows: false, }, } )
Functions ¶
func Completions ¶
func Completions[T any](values []T, fields map[string]func(T) string, opts ...Options) (results []string)
Completions returns a list of results that can be passed to a carapace.Action (described or not), to be used as completions.
func Details ¶
Details is almost identical to Table and requires a type parameter for displaying an object with more details. The headers function parameter can either be one also used for displaying the type in a table, or another with different output for all/some of the fields. If the headers are weighted, a newline is left between each group of headers (grouped by weight).
func FormatSmallID ¶
FormatSmallID returns a smallened ID for table display.
Types ¶
type Options ¶
type Options func(opts *opts) *opts
Options are functions allowing to customize or easily use table adjusment helpers.
func WithAutoSmallID ¶
func WithAutoSmallID() Options
WithAutoSmallID automatically truncates columns named "ID" to maximum 8 characters.
func WithCandidateValue ¶
WithCandidateValue sets the header name (field) to use as the completion candidate to be inserted for the given type.
func WithHeader ¶
WithHeader adds a specific header for the display using these options.
func WithSplitCandidate ¶
WithSplitCandidate will attempt to split the headers/fallbacks provided with WithCandidateValue() -if used-, and will generate aliased/non-aliased completions for each. This is useful when you don't use a unique ID with WithCandidateValue.