Documentation
¶
Overview ¶
Package output provides terminal output formatting for gridctl with amber color theme.
Index ¶
- Variables
- func ColorEnabled(w io.Writer) bool
- func EncodeJSON(w io.Writer, v any) error
- func IsTerminal(w io.Writer) bool
- func NewTableWriter(w io.Writer, plain bool) table.Writer
- func SetDefaultLevel(l slog.Level)
- func SetNoColor(disabled bool)
- func Suggest(input string, candidates []string) string
- type ContainerSummary
- type GatewaySummary
- type MCPServerRollup
- type Printer
- func (p *Printer) Banner(ver string)
- func (p *Printer) Containers(containers []ContainerSummary)
- func (p *Printer) Debug(msg string, keyvals ...any)
- func (p *Printer) Error(msg string, keyvals ...any)
- func (p *Printer) Gateways(gateways []GatewaySummary)
- func (p *Printer) Hint(format string, args ...any)
- func (p *Printer) Info(msg string, keyvals ...any)
- func (p *Printer) MCPServers(rows []MCPServerRollup)
- func (p *Printer) Print(format string, args ...any)
- func (p *Printer) Println(args ...any)
- func (p *Printer) Replicas(rows []ReplicaDetail)
- func (p *Printer) Section(title string)
- func (p *Printer) SetDebug(enabled bool)
- func (p *Printer) SetLevel(l slog.Level)
- func (p *Printer) SetPlain(plain bool)
- func (p *Printer) Summary(workloads []WorkloadSummary)
- func (p *Printer) Warn(msg string, keyvals ...any)
- type ReplicaDetail
- type Reporter
- type WorkloadSummary
Constants ¶
This section is empty.
Variables ¶
var ( ColorAmber = lipgloss.Color("#f59e0b") // Primary brand color ColorWhite = lipgloss.Color("#fafaf9") // text-text-primary ColorMuted = lipgloss.Color("#78716c") // text-text-muted ColorGreen = lipgloss.Color("#10b981") // status-running ColorRed = lipgloss.Color("#f43f5e") // status-error ColorGray = lipgloss.Color("#a8a29e") // text-text-secondary )
Amber color theme based on Gridctl web UI design system. Primary amber (#f59e0b) for key elements.
Functions ¶
func ColorEnabled ¶
ColorEnabled reports whether styled output should be emitted on w. Color is disabled when SetNoColor(true) was called, NO_COLOR is set and non-empty (https://no-color.org/), TERM is "dumb", or w is not a terminal.
func EncodeJSON ¶
EncodeJSON writes v to w as two-space-indented JSON. It is the shared encoder for every command's machine-readable output so schemas render consistently and never carry ANSI escapes.
func IsTerminal ¶
IsTerminal reports whether w is an interactive terminal. Callers use it to gate interactive chrome (spinners, prompts) that must never run against pipes or CI logs.
func NewTableWriter ¶
NewTableWriter returns a go-pretty table writer bound to w using the shared gridctl style. Plain rendering is used when forced by a --plain flag or when w is not a terminal, so piped output never contains box runes. Commands that render tables outside a Printer share this chokepoint instead of hand-rolling styles.
func SetDefaultLevel ¶
SetDefaultLevel sets the minimum level for subsequently created Printers. charmbracelet/log levels share slog's numeric values, so the conversion is direct.
func SetNoColor ¶
func SetNoColor(disabled bool)
SetNoColor disables (or re-enables) all styled output for the process, regardless of TTY detection. Wired to the global --no-color flag.
Types ¶
type ContainerSummary ¶
type ContainerSummary struct {
ID string
Name string
Type string // mcp-server, agent, resource
Image string
State string // running, exited, etc.
Message string // status message
PinStatus string // pinned, drift, approved, unpinned, or empty to omit column
}
ContainerSummary contains data for the container status table.
type GatewaySummary ¶
type GatewaySummary struct {
Name string
Port int
PID int
Status string // running, stopped
Started string // human-readable duration
CodeMode string // "on" or empty
}
GatewaySummary contains data for the gateway status table.
type MCPServerRollup ¶
type MCPServerRollup struct {
Name string
Type string // transport label: local-process, container, ssh, external, openapi
Replicas string // "N/M" for sets with replicas > 1, "—" for single-replica servers
State string // "healthy", "degraded (replica-N restarting, next in 4s)", "unhealthy"
Autoscale string // "min/current/max (target=N)" for autoscaled servers, empty for static
}
MCPServerRollup is one row of the rolled-up MCP-servers table shown by `gridctl status`. A server with a single replica uses "—" in the Replicas column to match the UX spec.
type Printer ¶
type Printer struct {
// contains filtered or unexported fields
}
Printer handles terminal output with amber-themed styling.
func NewWithWriter ¶
NewWithWriter creates a Printer with a custom writer.
func (*Printer) Containers ¶
func (p *Printer) Containers(containers []ContainerSummary)
Containers prints the container status table with amber styling.
func (*Printer) Gateways ¶
func (p *Printer) Gateways(gateways []GatewaySummary)
Gateways prints the gateway status table with amber styling.
func (*Printer) Hint ¶
Hint prints a short next-step suggestion. Hints are conversational chrome: they are suppressed when the writer is not a terminal so scripts, pipes, and JSON consumers never see them.
func (*Printer) MCPServers ¶
func (p *Printer) MCPServers(rows []MCPServerRollup)
MCPServers prints the rolled-up MCP-server status table. The AUTOSCALE column is shown only when at least one row has autoscale configured, so static-only stacks see an unchanged table.
func (*Printer) Replicas ¶
func (p *Printer) Replicas(rows []ReplicaDetail)
Replicas prints the per-replica detail table used by `gridctl status --replicas`. The AUTOSCALE column only appears when at least one row populates it.
func (*Printer) SetPlain ¶
SetPlain forces grep-friendly table rendering (no box-drawing) even when the writer is a terminal. Wired to per-command --plain flags.
func (*Printer) Summary ¶
func (p *Printer) Summary(workloads []WorkloadSummary)
Summary prints the final status table with amber styling.
type ReplicaDetail ¶
type ReplicaDetail struct {
Server string
Replica int
Handle string // PID for local-process, container id prefix for container-backed
State string
Uptime string
InFlight int64
Autoscale string // "min/current/max (target=N)" — repeated per replica row for server-level info, empty for static servers
}
ReplicaDetail is one row of the expanded `gridctl status --replicas` view.
type Reporter ¶
type Reporter struct {
// contains filtered or unexported fields
}
Reporter prints apply-phase progress. The base behavior is a static "<name>..." line on start and a "<name>... done" line on completion; when animate is enabled a spinner redraws the line in place instead. A nil *Reporter is a no-op so quiet mode can skip construction.
func NewReporter ¶
NewReporter creates a phase reporter writing to w. Animation runs only when w is an interactive terminal, the CI environment variable is unset, styling is not globally disabled (NO_COLOR, TERM=dumb, --no-color), and ACCESSIBLE is not requested; everything else gets static lines.
func (*Reporter) EndPhase ¶
EndPhase completes the running phase, printing its terminal status line. Safe to call when no phase is active.
func (*Reporter) StartPhase ¶
StartPhase begins a named phase. Any phase still running is finished successfully first, so call sites never have to pair Start/End manually across seams.
Pass spin=false for phases whose window carries foreign output (the docker pull/build slog stream): the phase then renders as static lines even on a TTY, so redraw frames never interleave with real output.