Documentation
¶
Overview ¶
Package ui provides terminal UI helpers for the ToolHive CLI.
Package ui provides shared styling helpers for the ToolHive CLI.
Index ¶
- Variables
- func PadToWidth(s string, w int) string
- func RenderClientStatusTable(clientStatuses []client.ClientAppStatus) error
- func RenderRegisteredClientsTable(registeredClients []RegisteredClient, hasGroups bool) error
- func RenderStatusDot(status rt.WorkloadStatus) string
- func RunClientSetup(clients []client.ClientAppStatus, availableGroups []*groups.Group) ([]client.ClientAppStatus, []string, bool, error)
- func VisibleLen(s string) int
- type RegisteredClient
- type TUILogHandler
Constants ¶
This section is empty.
Variables ¶
var ( ColorGreen = lipgloss.Color("#9ece6a") ColorRed = lipgloss.Color("#f7768e") ColorYellow = lipgloss.Color("#e0af68") ColorBlue = lipgloss.Color("#7aa2f7") ColorPurple = lipgloss.Color("#bb9af7") ColorCyan = lipgloss.Color("#7dcfff") ColorDim = lipgloss.Color("#4a5070") ColorDim2 = lipgloss.Color("#6272a4") ColorText = lipgloss.Color("#c0caf5") // ColorBg is the main TUI background — the same dark tone used by the statusbar. ColorBg = lipgloss.Color("#1e2030") )
Tokyo Night palette
Functions ¶
func PadToWidth ¶ added in v0.26.0
PadToWidth pads s (which may contain ANSI escapes) so its visible width equals w. If s is already wider, it is returned unchanged.
func RenderClientStatusTable ¶
func RenderClientStatusTable(clientStatuses []client.ClientAppStatus) error
RenderClientStatusTable renders the client status table to stdout.
func RenderRegisteredClientsTable ¶ added in v0.2.8
func RenderRegisteredClientsTable(registeredClients []RegisteredClient, hasGroups bool) error
RenderRegisteredClientsTable renders the registered clients table to stdout.
func RenderStatusDot ¶ added in v0.26.0
func RenderStatusDot(status rt.WorkloadStatus) string
RenderStatusDot returns a colored bullet for the given WorkloadStatus.
func RunClientSetup ¶
func RunClientSetup( clients []client.ClientAppStatus, availableGroups []*groups.Group, ) ([]client.ClientAppStatus, []string, bool, error)
RunClientSetup runs the interactive client setup and returns the selected clients, groups, and whether the user confirmed.
func VisibleLen ¶ added in v0.26.0
VisibleLen returns the number of visible characters in s, stripping ANSI escape sequences and counting multi-byte UTF-8 codepoints as one character.
Types ¶
type RegisteredClient ¶ added in v0.2.8
RegisteredClient represents a registered client with its associated groups
type TUILogHandler ¶ added in v0.26.0
type TUILogHandler struct {
// contains filtered or unexported fields
}
TUILogHandler is an end-of-pipeline slog.Handler that sends formatted WARN/ERROR records to a channel so the TUI can display them inside the dashboard instead of writing to stderr (which would corrupt the alt-screen rendering).
Because TUILogHandler is a terminal handler (it formats and dispatches records directly rather than delegating to an inner handler), it does not support WithAttrs/WithGroup chaining. Callers must not rely on slog.Logger.With to attach attributes through this handler; any attributes present on a record are inlined in Handle instead.
func NewTUILogHandler ¶ added in v0.26.0
func NewTUILogHandler(ch chan<- string, level slog.Level) *TUILogHandler
NewTUILogHandler creates a TUILogHandler that sends records to ch.
func (*TUILogHandler) Enabled ¶ added in v0.26.0
Enabled reports whether the handler handles records at the given level.
func (*TUILogHandler) Handle ¶ added in v0.26.0
Handle formats and sends a log record to the channel.
func (*TUILogHandler) WithAttrs ¶ added in v0.26.0
func (h *TUILogHandler) WithAttrs(_ []slog.Attr) slog.Handler
WithAttrs returns the receiver unchanged. TUILogHandler is an end-of-pipeline handler; pre-bound attributes from slog.Logger.With are silently dropped. See the type doc comment for details.