ui

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: Apache-2.0, MIT Imports: 12 Imported by: 0

Documentation

Overview

Package ui contains the shared theme, rendering helpers, and TTY utilities.

Index

Constants

This section is empty.

Variables

View Source
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

func HuhTheme(isDark bool) *huh.Styles

HuhTheme builds a huh styles set from the shared palette. isDark is passed through to huh.ThemeBase for baseline contrast handling.

func IsInteractive

func IsInteractive(f *os.File) bool

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 LogStyles

func LogStyles() *charmlog.Styles

LogStyles returns a charm log styles set themed to the shared palette.

func RenderSandbox

func RenderSandbox(w io.Writer, sb *sandbox.Sandbox)

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

func RenderSandboxJSON(w io.Writer, sb *sandbox.Sandbox) error

RenderSandboxJSON writes a single sandbox as indented JSON.

func RenderSandboxList

func RenderSandboxList(w io.Writer, sbs []*sandbox.Sandbox, now time.Time)

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

func RenderSandboxListJSON(w io.Writer, sbs []*sandbox.Sandbox) error

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

func RenderStatus(w io.Writer, tokens session.Tokens, found bool)

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

func SandboxFrame() lipgloss.Style

SandboxFrame returns the lipgloss style used for the credential box rendered after a successful `create`.

Types

type ConsoleJSON

type ConsoleJSON struct {
	URL      string `json:"url"`
	Username string `json:"username"`
	Password string `json:"password"`
}

type CredsJSON

type CredsJSON struct {
	AccessKey string `json:"access_key"`
	SecretKey string `json:"secret_key"`
}

type IdentityJSON

type IdentityJSON struct {
	Account string `json:"account"`
	UserID  string `json:"user_id"`
	ARN     string `json:"arn"`
	Region  string `json:"region"`
}

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL