display

package
v0.0.0-...-0f6999a Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func Details[T any](value T, fields map[string]func(T) string, opts ...Options) string

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

func FormatSmallID(id string) string

FormatSmallID returns a smallened ID for table display.

func Table

func Table[T any](values []T, fields map[string]func(T) string, opts ...Options) *table.Table

TableWith requires a type parameter consisting of a type for which a corresponding map of "Column Field" to a function generating its table value exits, passed as the fields function argument. The values argument is the list of objects to be displayed in the table, with options.

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

func WithCandidateValue(header, fallback string) Options

WithCandidateValue sets the header name (field) to use as the completion candidate to be inserted for the given type.

func WithHeader

func WithHeader(name string, weight int) Options

WithHeader adds a specific header for the display using these options.

func WithSplitCandidate

func WithSplitCandidate(sep string) Options

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.

func WithStyle

func WithStyle(style table.Style) Options

WithStyle sets the style of the table.

Jump to

Keyboard shortcuts

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