Documentation
¶
Overview ¶
Package columns ranks and styles the columns tui-builder writes for you. The evidence differs by caller (a JSON sample for `add exec`, a schema for the OpenAPI generator), so callers classify each column; this package holds the vocabularies, the ranking and the style.
Index ¶
- Constants
- func IdentityNames() []string
- func IsBookkeepingName(name string) bool
- func IsCheckName(name string) bool
- func IsCoordinateName(name string) bool
- func IsFailureCount(name string) bool
- func IsIDName(name string) bool
- func IsLinkName(name string) bool
- func IsLongName(name string) bool
- func IsStatusName(name string) bool
- func IsTimeName(name string) bool
- func SortByRank(cols []Column)
- type Column
- type Rank
- type Rule
- type Style
Constants ¶
const DefaultMax = 8
DefaultMax is how many columns are kept; the rest are written commented out.
Variables ¶
This section is empty.
Functions ¶
func IdentityNames ¶
func IdentityNames() []string
IdentityNames are the field names an identity is looked for under, in order, after any caller-specific choice.
func IsBookkeepingName ¶
IsBookkeepingName is a timestamp the store keeps rather than one about the thing: created_at, updatedAt, last_modified.
func IsCheckName ¶
IsCheckName reads a boolean's name as a check worth colouring: ready, healthy, ok, enabled…
func IsCoordinateName ¶
IsCoordinateName is a latitude or longitude.
func IsFailureCount ¶
IsFailureCount reads a number's name as a count of failures: restarts, errors, failures…
func IsLinkName ¶
IsLinkName is a URL or link to something: image_url, href, self_link.
func IsLongName ¶
IsLongName reads a field name as long text: description, message…
func IsStatusName ¶
IsStatusName reads a field name as a status: status, state, phase…
func IsTimeName ¶
IsTimeName reads a field name as a timestamp: created_at, updatedAt, creationTimestamp, ts…
func SortByRank ¶
func SortByRank(cols []Column)
SortByRank orders cols by rank, minor columns after short text, keeping the given order within each.
Types ¶
type Column ¶
type Column struct {
Path string
Title string
Rank Rank
// Bool is a boolean column (true/false values).
Bool bool
// Values are the distinct values seen (a sample) or declared (an
// enum), for status colours.
Values []string
// Sort is the comparator: "", "number" or "si".
Sort string
// Minor is a column worth less than any other short one, whatever
// its rank: a bookkeeping timestamp, a coordinate, an id or link, a
// nested object's other fields. It sorts after short text, before
// long text, and keeps its rank for its style.
Minor bool
}
Column is one column as the caller found it.
type Rule ¶
Rule is one colour rule: when the cell matches When, it's drawn in Color.
func StatusRules ¶
StatusRules writes colour rules for the vocabulary words among values, in the order seen, then the bad and warning catch-alls. No rule for a value outside the vocabulary, and none at all when no value is in it: unknown values render plain.
type Style ¶
Style is how a kept column is drawn.
func Styles ¶
Styles styles the kept columns: bold on the first identity column; status colours from the vocabulary, for values seen; booleans coloured only when named as a check; failure counts warn above zero; numbers and timestamps right- aligned; flex on the long-text column, else on the identity; a max_width of 20 on status columns.