columns

package
v1.28.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 16 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	FlagName       = "columns"
	MaxColumnWidth = 40
)

Variables

This section is empty.

Functions

func AddFlags

func AddFlags(flags *pflag.FlagSet)

AddFlags adds custom text-column selection to a command flag set.

func Project

func Project(raw any, columns []Column) ([]string, [][]string, error)

Project converts raw structured output into headers and text rows.

func Render

func Render(out io.Writer, headers []string, rows [][]string, availableWidth int) error

Render writes a plain, aligned table with display-width-aware truncation.

func RenderAutoWidth

func RenderAutoWidth(out io.Writer, headers []string, rows [][]string) error

RenderAutoWidth detects the output terminal width and falls back to 120 columns when the output does not expose a terminal file descriptor.

func RenderAutoWidthWithOptions added in v1.10.0

func RenderAutoWidthWithOptions(
	out io.Writer,
	headers []string,
	rows [][]string,
	options RenderOptions,
) error

func RenderWithOptions added in v1.10.0

func RenderWithOptions(
	out io.Writer,
	headers []string,
	rows [][]string,
	availableWidth int,
	options RenderOptions,
) error

func ValidateColumnFlags added in v1.7.0

func ValidateColumnFlags(helper cmdpkg.Helper, cfg config.Hook) error

Types

type Column

type Column struct {
	Header string
	Path   string
	// contains filtered or unexported fields
}

Column is a user-selected text column and its compiled field path.

func Parse

func Parse(values []string) ([]Column, error)

Parse compiles repeated or comma-separated HEADER=.field specifications.

func Resolve

func Resolve(cmd *cobra.Command, outType cmdcommon.OutputFormat) ([]Column, error)

Resolve reads and validates custom columns from cmd. An empty result means the command should use its built-in text columns.

type RenderOptions added in v1.10.0

type RenderOptions struct {
	// MinimumWidths prevents selected columns from shrinking below the
	// corresponding display width. Missing entries use the legacy minimum.
	MinimumWidths []int

	// NoTrunc preserves natural cell widths regardless of terminal width.
	NoTrunc bool
}

RenderOptions configures static table width allocation.

Jump to

Keyboard shortcuts

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