present

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package present is the sole home for charm.land/lipgloss/v2 styling (D-01). It consumes already-computed plain data (query.StatusResult, the files result struct) and emits colorized, sectioned output; internal/query and internal/mcp never import charm — the boundary the TUI-01 archtest (internal/cli/present/archtest) enforces at build time.

present must NOT read os.Getenv or call term.IsTerminal itself — real fd/env values are read only at the RunE call sites in internal/cli (D-03).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChoosePresentation

func ChoosePresentation(isTTY bool, noColor string) bool

ChoosePresentation reports whether the pretty (lipgloss) branch should render, per D-04/D-05: isTTY must be true AND NO_COLOR must be unset/empty. It is pure and side-effect-free — it must NOT read os.Getenv or call term.IsTerminal itself. Real fd/env values are read only at the RunE call sites (internal/cli/status.go, files.go, init.go, index.go, sync.go — D-03), which makes this the one shared, unit-testable branch selector every call site wires identically.

func RenderFiles

func RenderFiles(r query.FilesResult, w io.Writer) error

RenderFiles writes a lipgloss-styled rendering of r to w, mirroring the plain branch selection in internal/cli/files.go's RunE: r.Format == "tree" walks the FileTreeNode slice via writeFileTree; otherwise each FileEntry is rendered as a styled "Path (Language)" line. r is consumed read-only — the tree structure and file ordering are never recomputed here (D-02). Callers gate this behind ChoosePresentation (D-03); RenderFiles itself never reads a TTY/env value.

func RenderStatus

func RenderStatus(r query.StatusResult, projectPath string, w io.Writer) error

RenderStatus writes a lipgloss-styled rendering of r to w, walking the SAME section order as query.RenderStatusText (header → Project → worktree warning when present → Index Statistics → Nodes by Kind → Files by Language → advisories) with headerStyle/labelStyle/sectionStyle applied as structural chrome only (D-01/D-02). r is consumed read-only: counts, sort order, and wording are never re-derived here — only styling is added. Callers gate this behind ChoosePresentation (D-03); RenderStatus itself never reads a TTY/env value.

Types

type Progress

type Progress struct {
	// contains filtered or unexported fields
}

Progress is a hand-rolled, non-interactive, TTY-gated progress indicator (TUI-05, D-08/D-09). It writes exactly one lipgloss-styled spinner frame per progressTickInterval tick to the io.Writer supplied at construction — callers at the internal/cli RunE boundary MUST pass os.Stderr, never os.Stdout (D-08: progress must never reach the stdout/MCP JSON-RPC stream). Progress reads no stdin and never spawns a bubbletea Program — it is built from lipgloss styling plus a stdlib time.Ticker only (D-09/D-13), never charm.land/bubbles or charm.land/bubbletea.

Stop() terminates the ticker goroutine deterministically (T-06-08): it closes a stop channel and blocks until the goroutine has actually returned before clearing the line, so no goroutine is ever left running after Stop returns — the concurrency guarantee an interrupted or parallel index run depends on.

func NewProgress

func NewProgress(w io.Writer) *Progress

NewProgress constructs a Progress that writes exclusively to w. w is never defaulted or substituted internally — Progress has no reference to os.Stdout anywhere in its implementation; the TTY/stream choice is entirely the caller's (D-08).

func (*Progress) Start

func (p *Progress) Start(label string)

Start launches the single ticker goroutine and begins rendering frames labeled with label. Calling Start on an already-running Progress is a no-op (it does not launch a second goroutine).

func (*Progress) Stop

func (p *Progress) Stop()

Stop terminates the ticker goroutine deterministically: it closes the stop channel and blocks until the goroutine has confirmed it returned (via doneCh) before Stop itself returns — by the time Stop returns, the line-clear sequence has already been written and the goroutine is guaranteed gone (no leak). Calling Stop on a Progress that was never started, or calling it a second time, is a safe no-op (idempotent).

Jump to

Keyboard shortcuts

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