Help us shape the future of Go! Take the 2026 Go Developer Survey

livetui

package
v1.3.100 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package livetui cmd/skywire-cli/cliutil/livetui/livetui.go c4-vis-cli helper. Wraps any function that produces a string in a scrollable viewport that re-renders on a configurable tick. Used by CLI commands that want a watch(1)-style live refresh without taking a dependency on watch(1) and without the "every tick rewrites the whole screen" terminal-jump experience.

Use: build a Refresh callback that returns the snapshot the user should see RIGHT NOW (as a string). Pass it to Run with an interval. Run blocks until the user hits q / Ctrl+C; while it's running it calls Refresh every interval and pipes the result into a viewport that the user can scroll up/down independently of new frames arriving.

The viewport preserves scroll position when new content streams in — same Ink-style "scrollable while updating" pattern Claude Code uses, mirrored here for skywire CLI commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(refresh Refresh, opts Options) error

Run blocks running the TUI. Returns nil on user-initiated quit (q / Ctrl+C); returns the tea.Program error otherwise.

Types

type Options

type Options struct {
	// Title shown in the header. Defaults to "skywire live".
	Title string
	// Interval between Refresh calls. Defaults to 1s. Don't go
	// below ~200ms — bubbletea's render budget gets uncomfortable
	// and the spinner stutters.
	Interval time.Duration
}

Options tunes a Run invocation. All fields optional; sensible defaults below.

type Refresh

type Refresh func(ctx context.Context) (string, error)

Refresh produces the snapshot to display on each tick. ctx is canceled when the user quits the TUI; long-running Refresh implementations should respect it so the program shuts down promptly. Errors are surfaced in the header line (red) but don't terminate the loop — operators usually want to watch a transient error recover live rather than have the TUI die.

Jump to

Keyboard shortcuts

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