I’m happy to announce the release of console 0.9.0, a set of widgets for building nice-looking command-line tools. The main design constraint I tried to follow is that the output should look good both for a human at an interactive terminal and for scripts run in CI or other non-interactive loops (like LLM agents). Live rows are redrawn in place and everything useful the program printed is still there when it ends; piped output tries to be relatively clean.
You can use it with:
opam install console console-eio
The widgets in console are pure; console-eio is the driver that runs animations. There are a few limitation (including limited Windows support) but you can already use it to encode quite complex UX. For instance, here a few imitations of package manager frontends using console (recorded using k7):
Not exactly. As far as I understand, ratatui is mostly for full-screen terminal apps: it runs on the terminal’s alternate screen; you can’t scroll back when it runs and when the application exits the terminal goes back to where it was before. Ratatui also has an inline mode, but it seems a bit clunky as you have to set a fixed height for your output (I think I heard Rust people prefer indicatif for progress bars instead?)
With console your program stays a normal command-line tool. Only the lines that changed are redrawn (with the right amount of cursor rewind). You can scroll back, pipe the output to a file and see normal logs in your CI.
The inline redraw with cursor rewind is the part that interests me most — keeping normal scrollback intact instead of grabbing the alternate screen feels like the right default for CLI tools. When you say only changed lines are redrawn, does that hold up when output like a log line gets appended between live rows, or does that force a full repaint? Also curious how the pure widgets and the console-eio driver split responsibilities in practice, since that separation sounds like it keeps the core testable without an event loop.
I got console merged into Nixpkgs. Nixtamal 3.0.0, a Nix input pinner, was just released & is using console to power its TUI/CLI redesign (ditching the horrible, vibecoded old view since I couldn’t be bothered to learn all the ANSI codes & terminal weirdness—biding time for a library that fits the bill). The redrawing is the exact feature I needed.
When you say only changed lines are redrawn, does that hold up when output like a log line gets appended between live rows, or does that force a full repaint
Normally it should only redraw the lines that changed. If not, that’s a bug I’m happy to try to fix!
Also curious how the pure widgets and the console-eio driver split responsibilities in practice,
The plan was to have a pure view of the output, with a thin I/O layer for inputs and outputs. But the separation is a quite messy in 0.9.0. I’ve reworked this by adding a second backend to (make this cleaner) and the result is much better: see lwt: show the progress rows of an Lwt program by samoht · Pull Request #67 · samoht/ocaml-console · GitHub for the current WIP. The driver API now just a few lines (it doesn’t get deterministic clocks and multi-domain scheduling as the eio backend has, but that’s fine for “normal” use!).