Documentation
¶
Overview ¶
Package style is the CLI's single terminal palette, expressed as lipgloss colors. Every styled surface (explain/expand trees, doctor, status, the update and advisory notices, the init wizard) takes its colors from here so they read as one tool.
Styles render full 24-bit color; output is downsampled where it is written (see Writer), which is how lipgloss v2 handles terminals and NO_COLOR.
Two families:
- The OpenFGA palette, mapped from the openfga-dark theme of the OpenFGA VS Code extension (themes/openfga-dark.json in openfga/vscode-ext), for anything that shows model syntax: types, relations, restrictions.
- The melange brand palette (burnt orange, sand, warm gray, cream) for CLI chrome: headings, prompts, hints.
Status colors (Pass, Warn, Fail) are shared by both.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( TypeName = lipgloss.Color("#79ED83") // "Type": user, document RelationName = lipgloss.Color("#20F1F5") // "Relation": viewer, editor TypeRestriction = lipgloss.Color("#CEEC93") // "Type Restrictions": [user, group#member] Keyword = lipgloss.Color("#AAAAAA") // "Keyword" / "Value": has, on, →, : Comment = lipgloss.Color("#737981") // "Comment": tree connectors, dim prose )
OpenFGA palette.
var ( Pass = lipgloss.Color("2") // ANSI green, so it follows the terminal theme Warn = Accent // burnt orange Fail = lipgloss.Color("#FF5370") // OpenFGA "Invalid" OnStatus = lipgloss.Color("15") // bright white text on a Pass/Fail badge )
Status colors.
var ( Accent = lipgloss.Color("#E8813A") // burnt orange Muted = lipgloss.Color("#9C8E80") // warm gray )
Fixed brand colors for plain output. They do not adapt to the terminal background: that needs a background query, and a reply arriving after the CLI exits is echoed onto the user's prompt.
var StatusStyles = struct { Good, Warn, Bad, Muted, Bold lipgloss.Style }{ Good: New().Foreground(Pass), Warn: New().Foreground(Warn), Bad: New().Foreground(Fail).Bold(true), Muted: New().Foreground(Muted), Bold: New().Bold(true), }
StatusStyles are the shared styles for status-bearing output (doctor, status), so a pass, warning or failure looks the same everywhere. Write them through Writer so they are stripped when not on a terminal.
Functions ¶
func Enabled ¶
Enabled reports whether output to w should be colored by default: the same detection Writer uses, so every command agrees.
func New ¶
New returns a style that leaves tabs alone. lipgloss otherwise expands them to spaces on every Render, which would rewrite user text such as paths and error details.
func Writer ¶
Writer wraps w so styled text written to it is downsampled to what w supports, and stripped entirely unless w is a terminal with color and NO_COLOR is unset. colorprofile keeps bold and other non-color attributes under NO_COLOR; they are stripped too, so plain means plain. Wrapping an already-wrapped writer returns it unchanged: a second wrap would see a non-terminal and strip everything. Use it for output with no --color flag.