Documentation
¶
Overview ¶
Package ui contains the shared theme, rendering helpers, and TTY utilities.
Index ¶
- Variables
- func HuhTheme(isDark bool) *huh.Styles
- func IsInteractive(f *os.File) bool
- func LogStyles() *charmlog.Styles
- func RenderSandbox(w io.Writer, sb *sandbox.Sandbox)
- func RenderSandboxJSON(w io.Writer, sb *sandbox.Sandbox) error
- func RenderSandboxList(w io.Writer, sbs []*sandbox.Sandbox, now time.Time)
- func RenderSandboxListJSON(w io.Writer, sbs []*sandbox.Sandbox) error
- func RenderStatus(w io.Writer, tokens session.Tokens, found bool)
- func SandboxFrame() lipgloss.Style
- type ConsoleJSON
- type CredsJSON
- type IdentityJSON
- type SandboxJSON
Constants ¶
This section is empty.
Variables ¶
var ( Accent = lipgloss.Color("#874BFD") //nolint:gochecknoglobals // shared UI palette Success = lipgloss.Color("#02BA84") //nolint:gochecknoglobals // shared UI palette Warn = lipgloss.Color("#F2B033") //nolint:gochecknoglobals // shared UI palette Danger = lipgloss.Color("#EF4444") //nolint:gochecknoglobals // shared UI palette Dim = lipgloss.Color("245") //nolint:gochecknoglobals // shared UI palette )
Shared palette. Every form, frame, and log level pulls from these so the CLI has one visual identity.
Functions ¶
func HuhTheme ¶
HuhTheme builds a huh styles set from the shared palette. isDark is passed through to huh.ThemeBase for baseline contrast handling.
func IsInteractive ¶
IsInteractive reports whether the given file is attached to a terminal. A nil file always reports false.
This is the predicate used by huhprompt to decide whether to launch an interactive form or to bail out with session.ErrPromptUnavailable, and by the CLI to gate destructive confirmation prompts.
func RenderSandbox ¶
RenderSandbox writes the credential box for a provisioned sandbox to w. The box has a rounded border and contains account info, console login, programmatic credentials, and the expiry window.
A nil sandbox is treated as a no-op so callers can unconditionally render after Create without nil-checking.
func RenderSandboxJSON ¶
RenderSandboxJSON writes a single sandbox as indented JSON.
func RenderSandboxList ¶
RenderSandboxList writes a compact table of cached sandboxes: one row per entry, with a status column derived from the supplied "now". An empty slice prints a "(no sandboxes cached)" marker.
func RenderSandboxListJSON ¶
RenderSandboxListJSON writes a JSON array of sandboxes. A nil/empty slice renders as "[]" so callers can pipe through jq without a null special case.
func RenderStatus ¶
RenderStatus writes the status view (session info) to w. When the user has never logged in, the session block shows "(not logged in)".
func SandboxFrame ¶
SandboxFrame returns the lipgloss style used for the credential box rendered after a successful `create`.
Types ¶
type ConsoleJSON ¶
type IdentityJSON ¶
type SandboxJSON ¶
type SandboxJSON struct {
Kind string `json:"kind"`
Slug string `json:"slug"`
Credentials CredsJSON `json:"credentials"`
Console ConsoleJSON `json:"console"`
Identity IdentityJSON `json:"identity"`
StartedAt time.Time `json:"started_at"`
ExpiresAt time.Time `json:"expires_at"`
}
SandboxJSON is the machine-readable shape emitted by --json. It lives in the ui package so that internal/core/sandbox stays free of serialisation concerns.