examples/

directory
v0.0.34 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: Apache-2.0

README

Examples

Each directory under examples/ is a standalone Go module entry point. Run any of them with go run:

go run ./examples/cli/basic --help
go run ./examples/table

Most demos assume a real TTY for color and mouse support. Use Ctrl+C or the built-in Quit instructions to exit.

CLI highlights

  • cli/basic: Ground-up tour of commands, groups, aliases, and help output.
  • cli/interactive: Shows progressive interactivity with separate handlers for non-TTY vs TTY sessions, plus selection dialogs.
  • cli/streaming: Demonstrates streaming output, JSON event mode, and progress spinners.
  • cli/wizard: Multi-step configuration wizard that mixes prompts, validation, and summaries.
  • cli/todo: Hybrid CLI/TUI task manager with keyboard navigation and data persistence simulation.
  • cli/flags and cli/global_flags: Patterns for struct-based flag parsing and global configuration.

Run go run ./examples/<name> --help to inspect per-command usage.

TUI runtime demos

  • table and text: Workhorse primitives for grids, typography, and selection handling.
  • markdown: Renders markdown with syntax highlighting and adaptive layout.
  • runtime_http: Fetches GitHub data asynchronously and streams updates into the UI.
  • animation: Demonstrates the fluent animation API (.Rainbow(), .Pulse(), .Wave()) for text views.
  • declarative_animation and runtime_animation: Show CanvasContext for custom animations with access to the frame counter via ctx.Frame().
  • progress_spinners and flicker_free: Loading spinners, tick events, and rendering optimizations.
  • mouse and mouse_grid: Pointer interaction patterns.
  • file_picker, input_forms, checkbox, and password: Ready-made widgets (pickers, forms, toggle inputs).
  • tui/grapheme_input and tui/grapheme_table: Exercise the in-tree runewidth package — ZWJ emoji, VS16 sequences, keycaps, and CJK — through a live input and an alignment-critical table layout.
  • tui/reflow: Compares naive and runewidth-aware reflow so you can see where grapheme-aware width math matters.

Terminal techniques

  • hyperlink: Emits OSC 8 hyperlinks using the terminal package.
  • runtime_animation and runtime_counter: Show how to drive the TUI runtime without the CLI framework.
  • slog: Uses the colorized slog handler to inspect structured logs.
  • termprobe: Writes grapheme clusters to the host terminal and compares the reported cursor column against runewidth.StringWidth to surface renderer disagreements.
  • gif/grapheme_eval: Renders a corpus of grapheme clusters to GIF so you can eyeball how the gif package draws them.

Feel free to copy these examples as starting points for your own applications.

Directories

Path Synopsis
Example: browser - Markdown-based terminal web browser
Example: browser - Markdown-based terminal web browser
cli
basic command
Example: Basic CLI
Example: Basic CLI
flags command
Example: Flags and Validation
Example: Flags and Validation
global_flags command
Example: Global Flags and Configuration
Example: Global Flags and Configuration
Example: clipstack - Clipboard history manager
Example: clipstack - Clipboard history manager
Command crawl is a web crawler CLI with TUI display.
Command crawl is a web crawler CLI with TUI display.
env
config command
Example demonstrating the env package for configuration loading.
Example demonstrating the env package for configuration loading.
Example: envview - Interactive environment variable browser
Example: envview - Interactive environment variable browser
gif
Command gif converts terminal recordings (.cast files) to animated GIFs and provides utilities for creating animated GIFs.
Command gif converts terminal recordings (.cast files) to animated GIFs and provides utilities for creating animated GIFs.
grapheme_eval command
Example: grapheme_eval characterizes the gif terminal/emulator behavior for grapheme clusters and renders a few sample GIFs for manual inspection.
Example: grapheme_eval characterizes the gif terminal/emulator behavior for grapheme clusters and renders a few sample GIFs for manual inspection.
shapes command
Example: shapes demonstrates basic GIF creation with geometric shapes.
Example: shapes demonstrates basic GIF creation with geometric shapes.
terminal command
Example: terminal demonstrates terminal-style GIF creation with typed text.
Example: terminal demonstrates terminal-style GIF creation with typed text.
Example: gitgif generates an animated GIF visualizing recent git commits.
Example: gitgif generates an animated GIF visualizing recent git commits.
Example: gitscan - Interactive Git browser
Example: gitscan - Interactive Git browser
Command htmltomd converts HTML to Markdown from a URL or local file.
Command htmltomd converts HTML to Markdown from a URL or local file.
Example: paletteer - Terminal color palette designer
Example: paletteer - Terminal color palette designer
Example: Session Viewer
Example: Session Viewer
Example: Site Link Checker
Example: Site Link Checker
Example: sseview - Server-Sent Events stream viewer
Example: sseview - Server-Sent Events stream viewer
Command termprobe reports the host terminal's cell width for a battery of Unicode clusters.
Command termprobe reports the host terminal's cell width for a battery of Unicode clusters.
Example: termrec - Terminal session recorder and GIF exporter
Example: termrec - Terminal session recorder and GIF exporter
termsession
playback command
tui
animation command
Package main demonstrates animation with the declarative API.
Package main demonstrates animation with the declarative API.
border command
bracketed_paste command
checkbox command
claude command
code command
Example: Syntax-Highlighted Code Viewer
Example: Syntax-Highlighted Code Viewer
composition command
counter command
Package main demonstrates a declarative counter app.
Package main demonstrates a declarative counter app.
diff command
file_picker command
grapheme_input command
Package main demonstrates grapheme-aware text input.
Package main demonstrates grapheme-aware text input.
grapheme_table command
Package main demonstrates grapheme-aware column alignment in the Table view.
Package main demonstrates grapheme-aware column alignment in the Table view.
hyperlink command
inline_chat command
Example: inline_chat
Example: inline_chat
inline_counter command
Example: inline_counter
Example: inline_counter
inline_input command
inline_test command
Example: inline_test
Example: inline_test
input_display command
Package main demonstrates the declarative UI API for Wonton.
Package main demonstrates the declarative UI API for Wonton.
input_forms command
input_styles command
list command
markdown command
metrics command
mouse command
mouse_grid command
password command
print command
Package main demonstrates inline view printing without a full TUI application.
Package main demonstrates inline view printing without a full TUI application.
prompt_choice command
Example: prompt_choice
Example: prompt_choice
prompt_wizard command
Example: prompt_wizard
Example: prompt_wizard
reflow command
scrollback_demo command
Package main demonstrates the scrollback + live region pattern.
Package main demonstrates the scrollback + live region pattern.
scrollback_simple command
Package main demonstrates the simplest form of scrollback + live region.
Package main demonstrates the simplest form of scrollback + live region.
table command
text command
text_animation command
tui_command command
Example: URL to Markdown Clipboard Watcher
Example: URL to Markdown Clipboard Watcher
Example: Web Page Monitor
Example: Web Page Monitor

Jump to

Keyboard shortcuts

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