Documentation
¶
Overview ¶
Package theme is the single source of truth for the Jentic CLI's colour scheme. The palette is the company brand from the frontend theme (github.com/jentic/jentic-frontend-theme, ui/src/index.css accent tokens), so the CLI matches the web app. Every surface — help screen, install wizard, and command output — styles through this package.
Index ¶
- Constants
- Variables
- func Dimf(format string, a ...any) string
- func Field(label, value string) string
- func Headingf(format string, a ...any) string
- func Infof(format string, a ...any) string
- func Logo() string
- func LogoFor(name string) string
- func LogoForContext(ctx context.Context) string
- func LogoHeader(totalWidth int, rightLines []string) string
- func LogoHeaderFor(name string, totalWidth int, rightLines []string) string
- func LogoHeaderForContext(ctx context.Context, totalWidth int, rightLines []string) string
- func Successf(format string, a ...any) string
- func ThemeNameFromContext(ctx context.Context) string
- func VersionPanel(cliVersion, serverVersion string, serverRunning bool) []string
- func VersionPanelFor(s Styles, cliVersion, serverVersion string, serverRunning bool) []string
- func Warnf(format string, a ...any) string
- func WithContext(ctx context.Context, p Palette) context.Context
- func WithThemeName(ctx context.Context, name string) context.Context
- type Palette
- type Styles
- func (s Styles) Dimf(format string, a ...any) string
- func (s Styles) DotDown() string
- func (s Styles) DotFail() string
- func (s Styles) DotOK() string
- func (s Styles) DotWarn() string
- func (s Styles) Field(label, value string) string
- func (s Styles) Headingf(format string, a ...any) string
- func (s Styles) Infof(format string, a ...any) string
- func (s Styles) Successf(format string, a ...any) string
- func (s Styles) Warnf(format string, a ...any) string
Constants ¶
const ( SelectOn = "◉" SelectOff = "○" )
Selection glyphs (radio style): a filled ring marks the active/selected item, a hollow ring the inactive ones. Shared by the wizard hub menu and the huh form selects so selection looks identical everywhere.
Variables ¶
var ( Brand = lipgloss.Color("#A3CACC") // primary teal Orange = lipgloss.Color("#FDBD79") Yellow = lipgloss.Color("#F1E38B") Green = lipgloss.Color("#5EDEB9") // mint Pink = lipgloss.Color("#EDADAF") Blue = lipgloss.Color("#68BAEC") Red = lipgloss.Color("#DB3B0F") Muted = lipgloss.Color("#689296") // primary-500 grey-teal White = lipgloss.Color("#FFFFFF") )
Brand palette — hex values lifted straight from the company theme.
var ( Heading = Themes["dark"].Styles().Heading Step = Themes["dark"].Styles().Step Command = Themes["dark"].Styles().Command Dim = Themes["dark"].Styles().Dim Success = Themes["dark"].Styles().Success Warn = Themes["dark"].Styles().Warn Error = Themes["dark"].Styles().Error Info = Themes["dark"].Styles().Info Accent = Themes["dark"].Styles().Accent )
Shared styles. These are the RETIRED fixed-brand roles: they now DELEGATE to the dark palette's Styles() so dark output stays byte-identical while the migrated surfaces read palette-bound roles via StylesFromContext instead. Un-migrated call sites keep compiling against these package-level vars, which are pinned to dark. New code should prefer theme.StylesFromContext(ctx).
var Themes = map[string]Palette{ "dark": { Primary: Brand, Secondary: Blue, Error: Red, Success: Green, Warning: Orange, Muted: Muted, Command: Green, Accent: Yellow, Step: Yellow, }, "light": { Primary: lipgloss.Color("#4B0082"), Secondary: lipgloss.Color("#00696A"), Error: lipgloss.Color("#B22222"), Success: lipgloss.Color("#1B7A1B"), Warning: lipgloss.Color("#946A00"), Muted: lipgloss.Color("#6B6B6B"), Command: lipgloss.Color("#1B7A1B"), Accent: lipgloss.Color("#8A5A00"), Step: lipgloss.Color("#8A5A00"), }, "no-color": { Primary: lipgloss.NoColor{}, Secondary: lipgloss.NoColor{}, Error: lipgloss.NoColor{}, Success: lipgloss.NoColor{}, Warning: lipgloss.NoColor{}, Muted: lipgloss.NoColor{}, Command: lipgloss.NoColor{}, Accent: lipgloss.NoColor{}, Step: lipgloss.NoColor{}, }, }
Themes is the registry of built-in palettes, keyed by the names persisted in config (Context/Config theme) and accepted by --theme / JENTIC_THEME. The three keys are the closed set (14 BC-9): "dark", "light", "no-color". ResolveTheme falls back to "dark" for any unknown name.
The "dark"/"light" accents intentionally reuse the brand tokens (theme.go) so the runtime UI matches the banner; "no-color" zeroes every slot with lipgloss.NoColor{} so machine consumers never see an ANSI escape.
Functions ¶
func Field ¶
Field renders an aligned "label: value" pair with a muted label and a brand-coloured value, for the key/value listings commands print (dark alias).
func Logo ¶
func Logo() string
Logo renders the gradient "jentic" wordmark. Used by the help screen and the install wizard so the brand mark is consistent everywhere (dark alias).
func LogoFor ¶ added in v0.32.0
LogoFor renders the gradient "jentic" wordmark tinted for the named theme. dark reproduces the historical fixed gradient byte-for-byte; light/no-color re-tint. Unknown names fall back to dark.
func LogoForContext ¶ added in v0.32.0
LogoForContext renders the logo tinted for the theme resolved into ctx.
func LogoHeader ¶
LogoHeader renders the gradient wordmark with an optional block of status lines (e.g. version info) pinned to the top-right within totalWidth. When the terminal is too narrow to fit both (or rightLines is empty / width unknown), it falls back to just the logo. The returned string ends in a single newline (dark alias).
func LogoHeaderFor ¶ added in v0.32.0
LogoHeaderFor is LogoHeader tinted for the named theme (palette-aware).
func LogoHeaderForContext ¶ added in v0.32.0
LogoHeaderForContext is LogoHeaderFor tinted for the theme resolved into ctx.
func ThemeNameFromContext ¶ added in v0.32.0
ThemeNameFromContext returns the resolved theme name carried in ctx, or "dark" when absent (or when ctx is nil) — the name surfaces (e.g. the logo gradient) use to tint.
func VersionPanel ¶
VersionPanel formats the CLI and server versions as a single left-to-right status line for LogoHeader to pin flush against the right edge. The server segment shows the reported version when running, "running" if it is up but reports no version, or a dim "offline" when it is not reachable.
func VersionPanelFor ¶ added in v0.32.0
VersionPanelFor is VersionPanel tinted from the resolved Styles (palette-aware). It formats the CLI and server versions as a single left-to-right status line for LogoHeader to pin flush against the right edge. The server segment shows the reported version when running, "running" if it is up but reports no version, or a dim "offline" when it is not reachable.
func WithContext ¶ added in v0.32.0
WithContext stores the resolved Palette in the context for UI helpers that hold a context.Context but not the Audience.
Types ¶
type Palette ¶ added in v0.32.0
type Palette struct {
Primary lipgloss.TerminalColor
Secondary lipgloss.TerminalColor
Error lipgloss.TerminalColor
Success lipgloss.TerminalColor
Warning lipgloss.TerminalColor
Muted lipgloss.TerminalColor
// Command / Accent / Step are additional runtime slots the CLI's semantic
// roles need but that don't collapse cleanly onto the six above (e.g. Command
// is green and Success is also green+bold, but Step is yellow+bold and Accent
// is plain yellow — distinct from Warning's orange). They are carried on the
// Palette so `theme light` can re-tint them too; the dark values equal the
// historical fixed brand tokens so dark output is unchanged.
Command lipgloss.TerminalColor
Accent lipgloss.TerminalColor
Step lipgloss.TerminalColor
}
Palette is the semantic colour set the Audience layer (impl/3.1) styles UI accents from. It is deliberately SEPARATE from the brand palette/styles in theme.go: those are fixed company-brand tokens for the banner and installer wizard, whereas a Palette is mode/preference-resolved at runtime (dark, light, or no-color) and threads through HumanUX.
Fields are lipgloss.TerminalColor (the interface), NOT the concrete lipgloss.Color: the no-color palette assigns lipgloss.NoColor{} — a different concrete type — which does not fit a lipgloss.Color-typed field. TerminalColor is the interface both satisfy and what every lipgloss Style setter accepts.
func FromContext ¶ added in v0.32.0
FromContext returns the Palette carried in ctx, or the dark default if absent (or if ctx is nil — cobra hands a nil context to a command that never had one set, e.g. in unit tests that invoke a renderer directly).
func ResolveTheme ¶ added in v0.32.0
ResolveTheme applies the HUMAN-mode precedence ladder and returns the resolved Palette. The Stage-0 Mode gate (agent/service-account -> no-color) is applied by the root interceptor (impl/3.2 §2) BEFORE this function and overrides everything here; this function only owns the human-mode ladder (impl/1.4 §3):
--theme > NO_COLOR / non-TTY stdout > JENTIC_THEME > config theme > dark
flagOverride is the --theme value (may be ""); configTheme is ActiveState.ThemeName (the persisted config `theme`).
func ResolveThemeWithName ¶ added in v0.32.0
ResolveThemeWithName is ResolveTheme that also returns the resolved theme NAME ("dark"/"light"/"no-color"). The name is needed for surfaces whose tint isn't a single palette slot — notably the logo's 6-row gradient — so they can look up a per-theme gradient. The precedence ladder is identical to ResolveTheme; an explicit --theme still wins over the auto no-color rungs.
type Styles ¶ added in v0.32.0
type Styles struct {
Heading lipgloss.Style // section titles (Primary, bold)
Step lipgloss.Style // numbered/step emphasis (Step, bold)
Command lipgloss.Style // copy-pasteable command text (Command)
Dim lipgloss.Style // de-emphasised / helper text (Muted)
Success lipgloss.Style // success confirmations (Success, bold)
Warn lipgloss.Style // warnings (Warning)
Error lipgloss.Style // errors (Error, bold)
Info lipgloss.Style // informational accents (Secondary)
Accent lipgloss.Style // subtle highlight (Accent)
// contains filtered or unexported fields
}
Styles is the palette-bound set of semantic role styles every CLI surface renders through. It is the single seam that turns a runtime-resolved Palette into the lipgloss.Style roles that used to be fixed package-level vars in theme.go — so `--theme light`/`no-color` actually re-tint help, search, doctor, status, the wizard, and the logo instead of always emitting the dark-brand hex. Build one with Palette.Styles() (or StylesFromContext) at the top of a command and read st.Heading/st.Command/… instead of theme.Heading/….
The role→slot mapping is fixed here so every surface agrees; the dark palette (registry.go) carries slot values equal to the historical fixed tokens, so a dark Styles() reproduces the previous output byte-for-byte (guarded by a golden test).
func StylesFromContext ¶ added in v0.32.0
StylesFromContext resolves the role style set from the Palette carried in ctx (dark default when absent). This is the primary accessor for command bodies that hold a context.Context.
func (Styles) DotDown ¶ added in v0.32.0
DotDown is the palette-bound status glyph for an absent/offline item (hollow).
func (Styles) DotFail ¶ added in v0.32.0
DotFail is the palette-bound status glyph for a failed item.
func (Styles) DotOK ¶ added in v0.32.0
DotOK is the palette-bound status glyph for a present/healthy item (filled), mirroring the historical fixed cmdcore.DotOK but tinted from the resolved palette so light/no-color modes change it too.
func (Styles) DotWarn ¶ added in v0.32.0
DotWarn is the palette-bound status glyph for a degraded/warning item.
func (Styles) Field ¶ added in v0.32.0
Field renders an aligned "label: value" pair — a muted label and a bright value — matching the historical package-level Field helper, but tinted from the resolved palette.
func (Styles) Headingf ¶ added in v0.32.0
Headingf renders a printf-formatted string in the Heading role style.
func (Styles) Infof ¶ added in v0.32.0
Infof renders a printf-formatted string in the Info role style.