ui

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Overview

https://github.com/coder/coder/blob/main/LICENSE Extracted and modified from github.com/coder/coder

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisplayTable

func DisplayTable(out any, sort string, filterColumns []string) (string, error)

DisplayTable renders a table as a string. The input argument can be:

  • a struct slice.
  • an interface slice, where the first element is a struct, and all other elements are of the same type, or a TableSeparator.

At least one field in the struct must have a `table:""` tag containing the name of the column in the outputted table.

If `sort` is not specified, the field with the `table:"$NAME,default_sort"` tag will be used to sort. An error will be returned if no field has this tag.

Nested structs are processed if the field has the `table:"$NAME,recursive"` tag and their fields will be named as `$PARENT_NAME $NAME`. If the tag is malformed or a field is marked as recursive but does not contain a struct or a pointer to a struct, this function will return an error (even with an empty input slice).

If sort is empty, the input order will be used. If filterColumns is empty or nil, all available columns are included.

func Table

func Table() table.Writer

Table creates a new table with standardized styles.

Types

type TableSeparator

type TableSeparator struct{}

This type can be supplied as part of a slice to DisplayTable or to a `TableFormat` `Format` call to render a separator. Leading separators are not supported and trailing separators are ignored by the table formatter. e.g. `[]any{someRow, TableSeparator, someRow}`

Jump to

Keyboard shortcuts

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