Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyFilterFlag ¶
ApplyFilterFlag reads the --filter persistent flag from the root command and sets the corresponding flags on cmd. The filter string is a comma-separated list of key=value pairs where keys are matched to flag names (converted to kebab-case). If a flag is not found, the plural form (appending "s") is also tried.
Example: --filter "status=ACTIVE,currency=DKK" sets --status ACTIVE --currency DKK (or --statuses ACTIVE if --status doesn't exist).
func ExtractFields ¶
ExtractFields pulls column values out of data for each row. data may be a slice/array (one row per element) or a single map[string]any / struct (treated as one row).
func FilterFields ¶
FilterFields filters data to include only the specified field paths. It accepts map[string]any, []any, or []map[string]any data structures. Field paths use dot notation for nested fields (e.g., "worker.name"). If fields is empty, data is returned unchanged.
Types ¶
type Column ¶
Column describes a single table column: header text, the JSON field path used to extract values from data, and an optional fixed width.
func FilterColumns ¶
FilterColumns returns only the columns whose Field matches one of the comma-separated names in selected. If selected is empty, all columns are returned unchanged. The result preserves the order from selected.
type Formatter ¶
type Formatter struct {
// contains filtered or unexported fields
}
Formatter writes structured data as either JSON or an ASCII table.
func Auto ¶
Auto creates a Formatter that picks the format automatically: table when the writer is a terminal, JSON otherwise.
func (*Formatter) Print ¶
Print dispatches to PrintJSON or PrintTable based on the configured format.