Expand description
§rich-ext
Extensions layered on top of the faithful rich core, plus the internal
plugin registry. Anything that is not a faithful port of upstream rich
belongs here, so the core stays a clean, easily-synced mirror.
This crate carries its own independent SemVer (it does not track any upstream
version). See AGENTS.md → Versioning and docs/PLUGINS.md.
§Modules
- Errors and logs:
diagnostic,dashboard,stacktrace,hyperlink,log_handler(RichHandler,SpanView),adapters(EventSink;LogAdapterandEventLayerwith thelog/tracingfeatures),event,log_stream(log records parsed, filtered, collapsed and grouped, andChannelSink). - Data and authoring:
data,deps(Cargo dependency trees) andschema(JSON Schema trees and diffs, and the format-neutral schema model), all behind thedatafeature;derive,macros(themacrosfeature re-exportsrichf!and#[derive(Rich)]),inspect(rich.inspectfrom#[derive(Inspect)]),cli_doc(clapfeature forclap::Command). - Diffs and testing:
diff,testingandqa(testingfeature). - Terminals:
capabilities,fidelity,a11y,target,ansi_explain,sanitize,encoding,clipboard(OSC 52). - Workflows:
workflow,transfer,countdown,notify,cancel,table,badge,size_bar,format,redact(experimental). - Charts:
chart(sparklines, bars, histograms, line and scatter plots, gauges, heatmaps, status matrices, KPI cards and timelines; ratatui’s chart, canvas with a world map, and gauges). - Colour:
palette(Tailwind’s and Material’s palettes; HSL, HSV, Okhsv and Oklab colours, blends and gradients). - Inspectors:
source_view,hex,unicode_inspect,env_inspect. - Documents:
document(Org, AsciiDoc and man pages beside Markdown andrst, with format detection;syntaxfeature). - Layout and live output:
layout,live,surface(positioned drawing that writes only what changed). - Pipelines:
transform, anddata::transform(jsonpathfeature). - Files:
filetype(icons, colours, MIME types),fs(local times, owners),listing(entries, sorting, a tree walk),open(opener rules),file_ops(copy, move, delete with progress),trash(the FreeDesktop trash),git(status per file), andarchive(tar and zip listing and extraction;archivefeature).
The user guide (https://buchochelliq-labs.github.io/rs-rich-cli/guide/ext/) covers each module with compiled examples.
use rich::{Console, ColorSystem};
use rich_ext::ConsoleExt;
let mut console = Console::builder()
.force_terminal(true)
.color_system(Some(ColorSystem::Truecolor))
.build();
console.install_extensions(); // registers the number highlighter, etc.
let out = console.render_str_to_string("count=7");
assert!(out.contains("\x1b[1;36m7\x1b[0m"));Re-exports§
pub use highlighter::NumberHighlighter;pub use registry::BuiltinPlugin;pub use registry::ExtensionRegistry;pub use registry::HighlighterChoiceError;pub use registry::RegisteredPlugin;pub use registry::install_defaults;pub use sanitize::sanitize_terminal_controls;pub use theme::EXTRA_STYLES;pub use theme::extended_theme;pub use inspect::Inspect;pub use inspect::Inspectable;pub use inspect::inspect;pub use log_handler::RichHandler;pub use log_handler::SpanView;pub use rich_plugin_api as plugin;
Modules§
- a11y
- Accessibility: semantic text for screen readers (
semantic), user presentation preferences (policy) and colour checks (contrast). - adapters
- Facade adapters with explicit ownership; no global installation.
EventSinkis always here;LogAdapterneeds thelogfeature andEventLayerthetracingfeature. - ansi_
explain - Explain terminal output: tokenize text with escape sequences and describe every sequence in words.
- archive
- What is inside an archive, and taking it out: the entries of a tar,
gzipped tar or zip file (
entries), and extraction into a directory (extract) that never writes outside it. A file manager previews an archive with the listing and extracts it with Yazi’sextractopener. - badge
- Compact badges and status chips for statuses, labels, links and metadata.
- cancel
- A shared cancellation flag for workflows: task trees, transfers, retries.
- capabilities
- Terminal capability detection with provenance. No probes: every answer is
derived from environment variables and tty facts supplied through an
Environment, so detection is deterministic under aMapEnvironment. - chart
- Charts drawn with text: sparklines, bars, histograms, line and scatter plots, and the KPI and status renderables a dashboard is made of (gauges, heatmaps, status matrices, KPI cards and timelines).
- cli
- Optional CLI conveniences, kept outside the faithful command parser.
- cli_doc
- CLI authoring: describe a command once, then render its help, errors, shell completions, Markdown and man pages, config reference and config precedence through rich.
- clipboard
- Copy to the terminal’s clipboard with OSC 52 (#488), and the text a table cell or row copies as (#434).
- countdown
- Retry and rate-limit countdowns: a
Backoffpolicy, theRetryStatusandRateLimitlines, a shrinkingCountdownBar, andCountdownWait, which waits while showing the time left. - dashboard
- A dashboard over many diagnostics: counts by level, the most frequent codes, and every diagnostic grouped by file in location order.
- data
- Structured data: a format-neutral document tree, parsers that fill it, and views that render it.
- deps
- Cargo dependency graphs (#248), read from
cargo metadata. - derive
- The runtime behind
#[derive(Rich)](themacrosfeature). - diagnostic
- Compiler-style diagnostics. They render supplied source only; no filesystem or clock access.
- diff
- Diffs: an engine, terminal views and the inputs they read.
- document
- Documentation formats: Markdown, reStructuredText, Org, AsciiDoc and man
pages, behind one
DocumentFormatinterface. - dsp
- Signal processing for live views of audio and other sampled data: a
fast Fourier transform, a Hann window and magnitude spectra; test
signals (tones, harmonic partials, noise and a mix of them); trigger
detection, as an oscilloscope’s; a spectrum’s peak and log-spaced
bands, with levels that fall under gravity (
Falloff), as a bar spectrum’s (cava’s); and the frequencies of musical notes, in equal temperament or scope-tui’s table (NoteTable), with the note nearest a frequency, and aTunerreading a spectrum’s note and cents, smoothed. - encoding
- Explicit text decoding for CLI and application inputs.
- env_
inspect - Inspect environment variables and PATH-like lists.
- event
- Typed, ordered events. Time and context are supplied by the caller.
- fidelity
- Graceful degradation: pick how rich output may be, then render at that level.
- file_
ops - File operations as a file manager runs them: copy, move, link, delete
and trash, reporting progress as they go and stopping when cancelled, with
Yazi’s rules for names that are taken (a copy gets
_1,_2… before its extension) and for directories pasted into themselves (refused). - filetype
- File-type icons, colours and MIME types, for file managers and pickers: the glyph and colour Yazi shows by default for a file, a MIME type guessed from a name or from the first bytes, Yazi’s type colours, and whether a Nerd Font is likely in use.
- format
- Semantic formatters: sizes, rates, durations, times, percentages and numbers as people read them.
- frame
- Frames: a rendered result as rows of styled runs (#226).
- fs
- What a file listing shows beside a name: times in the local time zone, and the names of a file’s owner and group.
- git
- Git’s view of a working tree, file by file: what
git statussays of each path (modified, added, untracked, ignored, …), read fromgit status --porcelain=v1 -zin a subprocess, with no git library. A file manager shows it as a sign beside each name, as Yazi’sgitplugin does; a directory takes the most pressing change inside it. - gradient
- Text coloured along a gradient:
GradientTextputs each character of aTextat its place along two or more colours, across, down or corner to corner, throughpalette::gradient. - graphics
- What a terminal can draw beyond text (#573): the graphics protocol, and the size of one cell in pixels.
- hex
- A byte and hex inspector in the style of
hexdump -C. - highlighter
- Example extension: a number highlighter.
- hyperlink
- Semantic hyperlinks for URLs, paths, source locations and references.
- inspect
- A report on a Rust value, laid out as upstream’s
rich.inspectlays out its report on a Python object (rich/_inspect.py, #796). - layout
- Bounded extension layouts.
- listing
- Directory listings as a file manager shows them: the entries of a
directory with what a row needs (size, mode, times, owner, where a link
points), sorted as Yazi sorts them,
and the cells its line modes write; plus a directory
walkfor finders. - live
- Synchronous single-writer coordination for inline terminal regions.
- log_
handler - A log sink in the style of upstream
rich.logging.RichHandler. - log_
stream - Log streams: records read from JSON Lines or plain-text logs, then filtered, collapsed and grouped (#724).
- macros
- Convenience macros and the print helpers they use.
- markdown_
export - GitHub-flavoured Markdown from renderables, for pull request comments, issue bodies and job summaries.
- notify
- Transient notifications for command-line apps: small toasts that appear beside live output and vanish when they expire, without a full-screen UI.
- open
- Which program opens a file: Yazi’s
[opener]and[open]tables as data. AnOpenersays how to open (the editor, the system’s opener, a folder view, a shell command, or extracting an archive) and whether it takes the terminal; aRulepicks openers by MIME type or name glob;Rules::matchinggives the openers for a file, the first one what Enter uses. - palette
- Colour palettes, and colours made from numbers: Tailwind CSS’s and
Material Design’s palettes as
#rrggbbconstants, and helpers that make arich::Colorfrom HSL, HSV, Okhsv or Oklab, or mix colours. - plugin_
loading - Runtime plugins: native libraries and WASM modules loaded from a path.
- qa
- Render quality tooling: screenshots, layout stress, lint, explain, profiling, fuzzing, a capability matrix and benchmarks.
- qr
- QR codes drawn with text:
QrCodeencodes text or bytes and draws the modules two to a cell with half blocks, inside a quiet zone, so a phone can read it off the terminal. - redact
- Redact secrets from strings, terminal output, rendered segments and exports.
- registry
- The extension registry: where plugins are hosted.
- rst
- reStructuredText, rendered as
rich-rst2.2.0 renders it: theRestructuredTextrenderable that rich-cli’s--rstprints. - sanitize
- Opt-in input sanitizing for terminal-control bytes.
- schema
- Schemas drawn as trees (#244), what changed between two (#268), and how
a schema evolved (#347), for JSON Schema, SQL DDL, Arrow and anything
else in the format-neutral
model. - size_
bar - A compact bar for a size relative to a total or a limit.
- source_
view - A line-numbered, searchable view of a source file.
- sql
- A small SQL highlighter in pure Rust: no syntect, no C, no dependencies.
- stacktrace
- Stack traces from Rust, Python, Java and JavaScript, in one shape.
- surface
- Positioned drawing: render any rich renderable into a rectangle of the terminal, and write only the cells that changed.
- syntax
- Warming up syntax highlighting before it is first needed.
- table
- Table data operations layered on the core
rich::Table. - target
- Explicit destinations for deterministic, nested rendering. No environment probes.
- testing
- Deterministic snapshots for downstream render regression tests.
- theme
- Extra named styles layered on the upstream theme.
- transfer
- Download and upload progress: byte counts with a smoothed rate, an ETA, retries and cancellation.
- transform
- Composable transforms: rewrite what is about to be rendered, one stage at a time.
- trash
- The desktop trash, as the FreeDesktop.org trash
specification
keeps it:
putmoves a file or directory to the trash with a note of where it was and when,listreads what is there,restoreputs an item back andpurgedeletes it for good. File managers on Linux and the BSDs (GNOME Files, Dolphin, Thunar, Yazi throughtrash-cli) share this trash, so what is put here shows up in theirs. - unicode_
inspect - Inspect text one grapheme cluster at a time.
- workflow
- Workflow renderables: commands, task trees and completion summaries.
Macros§
- assert_
render_ eq - Assert a renderable renders as
expectedatwidth(default 80) through a plain, deterministic target; trailing whitespace is ignored. - assert_
rich_ eq - Assert two strings are equal; on failure, panic with a rendered line diff.
- assert_
rich_ json_ eq - Assert two
Serializevalues are equal as JSON; on failure, panic with a diff of both pretty-printed. - assert_
snapshot_ eq - Assert two
RenderSnapshots are equal; on failure, panic with their ANSI diff (style-only changes marked~) and the first differing field. - markup
- Check a markup literal at compile time and return it as
&'static str. Acceptskeys[...]before the literal, asrichf!does. - rich_
dbg dbg!throughPretty: prints[file:line:column] expression = valueto standard error with the value highlighted, and returns the value.- rich_
eprintln - Print checked markup to standard error.
- rich_
inspect - Print a report on a value to standard output, its source text in the
title. Options follow as
name = value:help,methods,docs,private,sort,value,types,variants,all,title,max_depth. - rich_
panel - A panel around a renderable, or around markup when given a string literal.
Optional
title = …andsubtitle = …follow. - rich_
println - Print checked markup to standard output:
rich_println!("[bold]{x}[/]"). - rich_
progress - Iterate with a progress bar on standard output: core’s
track. - rich_
table - A table from a header row and cell rows; each cell is anything
Display. Headers and cells are displayed literally, never parsed as markup. - rich_
trace - Print checked markup to standard error after a dim
file:line— a quick trace line. For log pipelines, routelog/tracingthroughRichHandler. - rich_
tree - A tree from nested labels:
rich_tree!("root" => ["a", "b" => ["c"]]). Labels are displayed literally, never parsed as markup. - richf
- A
Textfrom checked markup withformat!-style placeholders. - style
- A
Styleparsed at compile time:style!("bold red on white"). - theme_
key - A theme key checked against the default theme:
theme_key!("repr.number")expands to the&'static str.
Traits§
- Console
Ext - Ergonomic extension methods on the core
Console.
Attribute Macros§
- inspect
- Record an inherent
implblock’s methods forrich_ext::inspect: eachfn’s name, signature as written, doc comment, and whether it ispuborasync. Mark the type#[inspect(methods)]to list them; one block per type.#[inspect(skip)]on a method leaves it out.