tinsel
Clean, pink-hued terminal output for Rust CLIs, with a little sparkle. Live step lists, spinners, tables, trees, prompts and error reports that all look like they belong together. Zero dependencies.
use *;
let live = new;
let build = live.step;
let upload = live.step;
build.start;
build.done;
upload.start;
upload.progress;
upload.done;
live.finish_with_card;
deploy my-app → production
● Build 1.2s
● Upload 1.7s
╭────────────────────────────────────────────────────────────────────────╮
│ ● deployed in 3.8s │
│ │
│ url https://my-app.example.com │
╰────────────────────────────────────────────────────────────────────────╯
Why tinsel?
Most CLIs bolt together a spinner crate, a table crate, a prompt crate and a colour crate, and end up looking like four different programs. tinsel is one small library with one visual language: pink accents, quiet greys, eased animation, and a twinkle when something finishes.
- It learns: steps remember how long they took, so next run a spinner becomes a real estimate:
usually 42s · 18s left - It knows if you're watching: switch windows during a long run and you get a desktop notification when it ends; come back and whatever finished meanwhile twinkles
- It fits your terminal: detects light and dark backgrounds and redraws the palette to suit, or in another accent colour for your brand
- It speaks JSON too: one switch turns every step, message and error into JSON lines for tools, or quiets everything but problems
- Zero dependencies: nothing in your lockfile but tinsel
- One shape for everything: one-liners print; anything bigger is a
Blockyou can print, format, or test - Builders that read like the output:
Card::success("deployed").kv("url", …) - Errors you can match on: prompts return
prompt::Error::Cancelled, not a mysteryio::Error - Behaves in CI: no colour or animation when piped,
NO_COLORrespected, plain[ok] Build (1.2s)lines in logs - Panics stay tidy: a panic mid-run leaves the last frame on screen and prints a proper report, not a scrambled terminal
- Testable:
set_color_mode(ColorMode::None)and.plain()give you exact text to assert on, andLive::headlessruns a display on a clock you control
Install
Quickstart
One task with a spinner, then a message:
let files = spin;
success;
A step list for anything with stages: see the example at the top. Steps can run at the same time from different threads, have sub-steps, and log lines above the display:
let build = live.step;
let targets = ; // drawn indented, folded once they pass
build.start;
scope;
build.done;
live.log; // printed above, kept on screen
Progress bars can be a thin line (the default) or a waveform that lights up as it plays
through, like an audio track: Live::new(…).with_bar(BarStyle::Waveform).
Run real commands as steps. The latest line of output shows as the step's detail; if it fails, its last lines stay under it:
use Command;
build.run?;
push.command
.timeout
.retries
.run?;
fetch.retry?; // any closure returning a Result
See where the time went, with live.finish_with_timeline():
Build ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7s
linux ━━━━━━━━━━━━━━━━━━━━━━━ 1.2s
macos ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.7s
Publish ━━━━━━━━━━━━━ 0.7s
──────────────────────────────────────────────
0s 2.9s
A loop with a progress bar:
use ProgressIterator;
for file in files.iter.progress
Ask questions, and handle someone pressing Ctrl-C. Long lists filter as you type:
use prompt;
match select
Text questions can validate, and ask again until the answer passes:
let port = new
.placeholder
.validate
.ask?;
let replicas: u32 = number?;
let launch = date?; // a calendar
let notes = editor?; // opens $EDITOR
let region = new.suggestions.ask?; // Tab completes
let path = new.paths.ask?; // like a shell
confirm_typing?; // type it to go on
Help that looks like the rest of your CLI, with a short entrance on a terminal: lines fade in one after another while the name shimmers:
new
.version
.usage
.command
.flag
.example
.animate;
Documents: tinsel::markdown(changelog).page() draws Markdown (headings, lists, tables,
code coloured by language) and pages it if it's long; tinsel::json(body)? indents and
colours JSON.
Show data:
use ;
new
.row
.row
.sort_by_desc // by value: 1.2s before 84ms
.border
.print;
Full-screen apps: dashboards, pickers, little toys. Write a struct, draw it in view,
change it in event; app::run takes over the screen and gives it back afterwards (even on
a panic). Panels shimmer when focused, lists scroll themselves, and numbers can be drawn big:
use ;
run?; // q or Esc quits
Anything tinsel draws (tables, trees, cards, any Block) goes straight into a panel, next to
List, Tabs, Plot, Stat, big text, hints and twinkling Sparkles.
app::snapshot(&app, 80, 24) draws a frame without a terminal, for tests.
Report an error with its whole cause chain:
from_error
.hint
.eprint;
✕ couldn't start
╰─ couldn't read app.toml
╰─ No such file or directory (os error 2)
→ create app.toml, or pass --config <path>
…and point at the problem:
new
.cause
.code
.eprint;
✕ couldn't read app.toml
╰─ port must be a number
╭─ app.toml:3
2 │ host = "0.0.0.0"
3 › port = "eighty"
│ ^^^^^^^^ not a number
4 │ workers = 4
Panics, drawn the same way, with the terminal put back first:
For scripts and tools, one switch from a --json or --quiet flag:
set_output; // or TINSEL_OUTPUT=json
{"event":"step","title":"deploy","step":"Build","path":["Build"],"state":"done","secs":1.204}
{"event":"error","title":"couldn't start","causes":["couldn't read app.toml"],"code":[],"hint":"…"}
See it
What's in it
| live work | Live step lists with sub-steps, parallel steps and log · commands as steps with timeouts and retries · timeline · spin / try_spin · Progress with rate and time left, unknown or growing totals · .progress() on any iterator · bars as a line or a waveform · seven Spinners (sparkle twinkles, and is the default) |
| messages | success · info · warn · error · hint · counter · title · rule · callout · Report (with code excerpts) |
| data | Table (numbers right-align and sort by value, units and all; borders, wrapping, footers, highlighted rows) · Tree · pairs · columns |
| charts | sparkline · bars · meter · histogram · heatmap |
| code | diff · Code excerpts with syntax colouring (Rust, TOML, JSON, YAML, shell, Python, JS), a highlighted line and a caret under the problem |
| documents | markdown · json · Help with an animated entrance · Block::page |
| inline | badge · link (clickable) · Card · paint, bold, dim, italic, underline, gradient |
| apps | app::run full-screen apps · Panel · List · Tabs · Plot · Stat · big · hints · Sparkles · Rect layout with rows / columns · keys, mouse and resize events · app::snapshot for tests |
| questions | prompt::confirm · input / Input (validation, placeholders, line editing) · password · number · date · select · multiselect (filter as you type) · editor · suggestions and path completion · confirm_typing |
| setup | install_panic_hook · set_output (Json, Quiet) · set_accent · set_theme · set_color_mode · timings |
| helpers | text::{width, pad, truncate, wrap, strip_ansi} · format::{bytes, duration, count, ago, plural} |
Full reference with examples for every item: docs.rs/tinsel.
Testing what you print
Force plain output, then assert on exact text:
The colour mode is process-wide, so keep tests that need real colour codes in their own
file under tests/ (Cargo runs each file as a separate process).
A Live display can run headless, on a clock that only moves when you say:
Things it does on its own
Estimates from history. Live steps remember their durations in ~/.cache/tinsel (or
$XDG_CACHE_HOME/tinsel), one small file per program. A step with no progress of its own
gets an estimate bar from its recent median, and says slower than usual when it is. Only
successful steps on a terminal are recorded. Live::remember_as("name") picks the file,
.no_history() or TINSEL_NO_HISTORY=1 turns it off. tinsel::timings(Some("my-app"))
shows what's been learned, and flags a step whose last run was unusually slow.
Focus. In terminals that report window focus (iTerm2, kitty, WezTerm, Ghostty,
Alacritty, foot, …), animation slows while you're away, a run of 10s or more that finishes
while you're away sends a notification (.notify_after(…), .no_notify()), and returning
re-twinkles what finished. Keys typed during a run are held back from the display and handed
to the shell afterwards. TINSEL_NO_FOCUS=1 turns all of this off. tinsel::notify sends a
notification yourself.
Tall displays. A Live display taller than the terminal leaves its top rows in
scrollback and keeps redrawing what fits, so long step lists don't scramble the screen.
Theme. Decided once from TINSEL_THEME=light|dark, then COLORFGBG, then by asking the
terminal for its background colour. Override with tinsel::set_theme.
Accent. Pink unless TINSEL_ACCENT (violet, blue, teal, orange, or a hue in
degrees) or tinsel::set_accent says otherwise. Every pink moves, including the faint tint
in the greys; red, amber and sage keep their meaning.
Platform notes
Everything works on macOS, Linux and Windows. Prompts read single keypresses with stty on
Unix and the console API on Windows (Windows Terminal or a Windows 10+ console). Focus
awareness, terminal background detection and the Ctrl-C handler that restores the cursor are
Unix only; on Windows they quietly do nothing.