Rich
Rich is a comprehensive library for building sophisticated command-line interfaces and terminal applications. It provides a robust console formatting engine and a layout framework that enables developers to render rich text, syntax-highlighted code, and complex data structures directly in the terminal. By utilizing a recursive constraint-based layout engine, the library allows for the creation of hierarchical grids, panels, and trees that maintain their structure even as terminal dimensions change.
What distinguishes the library is its ability to manage persistent, real-time terminal interfaces through live display management and buffered stream handling. It offers granular control over output through a protocol-based rendering system, allowing developers to define custom representations for objects and manage complex visual arrangements. The library also includes a specialized diagnostic suite that automatically captures and transforms raw stack traces into human-readable, syntax-highlighted error reports, complete with local variable inspection.
Beyond its core rendering capabilities, the library provides a suite of tools for data visualization and user interaction. This includes support for nested progress tracking, animated status indicators, and interactive input prompts. Developers can apply consistent visual branding across their applications using a centralized markup-based styling system, which supports reusable themes, color palettes, and text attributes for precise alignment and formatting.
The library automatically detects the host terminal environment to ensure compatibility and visual consistency across different systems.
Features
- Command Line Interface Frameworks - Building professional terminal applications with rich text, complex layouts, and interactive elements that improve user experience.
- Console Formatting Engines - A rendering engine that transforms structured data and text into styled, color-coded, and human-readable output for terminal environments.
- Constraint-Based Layout Engines - A recursive solver calculates the dimensions of nested regions and components to ensure content fits within the available terminal space.
- Terminal UI Frameworks - A library for building sophisticated command-line interfaces with support for complex layouts, interactive components, and rich text styling.
- Grid Layouts - The library positions content precisely across the screen by removing borders and headers to create clean, column-based structures that align information without unnecessary visual clutter.
- Terminal Layout Engines - The library provides granular control over terminal layouts by yielding multiple renderable segments from class methods to manage complex output arrangements.
- Terminal Layout Managers - The library splits screen areas into rows and columns to organize complex terminal interfaces into hierarchical sections that are easy to identify and manage during runtime.
- Data Visualization Components - A collection of tools for rendering tables, trees, progress bars, and syntax-highlighted code blocks directly within the terminal.
- Embedded Data Renderers - The library embeds structured data displays directly into larger UI components like panels or tables to create organized and visually consistent terminal dashboards.
- Loading Indicators - The library displays animated loading indicators alongside status messages while background tasks run, keeping the terminal interface active without disrupting other printed content.
- Console Style Definitions - The library creates reusable text styles using simple string syntax to apply colors, background highlights, and formatting attributes like bold or italics to console output.
- Live Display Management - The library maintains a persistent terminal interface that automatically refreshes dynamic content at a set interval to provide real-time updates for long-running processes or monitoring tasks.
- Rich Content Renderers - The library outputs formatted text, syntax-highlighted code, and complex data structures to the terminal using built-in protocols that handle visual styling and structural layout automatically.
- Terminal UI Layouts - Organizing console output into hierarchical grids, panels, and trees to manage information density in complex command-line interfaces.
- Interactive Prompts - The library requests information from users using styled text and colors while maintaining standard line editing capabilities and command history for a professional command-line experience.
- Data Pretty Printers - The library displays nested data structures with configurable indentation and truncation settings to make large objects and long strings easier to read in the terminal.
- Exception Traceback Formatters - A global handler captures stack frames and local variables to transform raw error data into syntax-highlighted, human-readable reports.
- Traceback Filters - The library filters out irrelevant modules or file paths from error reports to highlight application-specific code and reduce noise during the debugging process.
- Real Time Process Monitors - Creating dynamic terminal dashboards that display live progress bars, status spinners, and updating metrics for long-running background tasks.
- Iterable Progress Trackers - The library updates progress displays automatically by wrapping any iterable sequence in a function that reports completion status after processing each individual item in the collection.
- Hierarchical Progress Trackers - The library displays hierarchical task completion by creating inner progress trackers that report status updates within the context of a primary parent progress bar.
- Layout Constraints - The library restricts specific regions to a fixed number of rows or columns to ensure that critical interface elements maintain their size even when the terminal window resizes.
- Terminal Output Managers - The library redirects standard output and error streams to protect the integrity of live display layouts while supporting nested components for complex terminal-based user interfaces.
- Terminal Environment Detectors - The library automatically identifies the current terminal environment to adjust ANSI control codes, ensuring output remains clean and readable when redirected to files or external applications.
- Terminal Data Visualizers - Presenting structured data, logs, and complex objects in a readable, color-coded format directly within the console environment.
- Concurrent Progress Tracking - The library manages multiple concurrent tasks and custom data columns by using a context manager to update progress displays manually as work moves through different stages.
- Buffered Streams - The system intercepts standard output streams to maintain persistent display regions and prevent visual corruption during dynamic content updates.
- Table Columns - The library specifies headers, widths, and alignment attributes to structure raw data into clear, readable columns that improve the presentation of information within the terminal.
- Error Reporters - A diagnostic component that captures and displays detailed, color-highlighted stack traces to simplify debugging and error analysis in applications.
- Exception Reporters - The library registers a system-wide exception listener that automatically captures and displays uncaught errors with syntax highlighting and local variable inspection to simplify troubleshooting.
- Error Reporting Interfaces - The library displays detailed error reports in the console, including local variables for each stack frame, to help developers identify the root cause of application failures.
- Exception Formatting - The library configures logging handlers to use specialized renderers that transform raw error tracebacks into readable, highlighted reports for faster debugging and clearer error analysis.
- Protocol-Based Renderers - Objects implement a standard interface to yield renderable segments, allowing the engine to recursively process and flatten complex UI hierarchies.
- Command Line Styling Themes - The library defines and manages centralized color and formatting schemes to ensure consistent visual branding and semantic styling across all parts of a command-line application.
- Syntax Highlighting Themes - The library selects and applies specific color palettes to syntax-highlighted code blocks to match terminal-native schemes or custom visual preferences.
- Code Highlighting - The library displays source code files with syntax highlighting directly from the command line by executing the built-in formatting tool on a target file.
- Style Object Managers - The library creates and combines formatting attributes programmatically to build reusable style configurations that can be applied consistently across multiple print operations.
- Code Line Numbering - The library enables line numbering for code blocks during initialization to improve the readability and reference of source code displayed in the terminal.
- Markup-Based Output Formatters - The library applies styles, hyperlinks, and symbols to text using a bracket-based syntax that supports nested formatting and character escaping for complex output requirements.
- Markup Parsers - A custom parser interprets bracketed syntax to apply nested formatting, colors, and hyperlinks to plain text streams before output.
- Markup String Renderers - The library displays formatted text within console output or UI components, with the option to toggle markup parsing to prevent syntax conflicts when handling raw data.
- Text Formatting Configurations - The library controls how text flows within output components by adjusting justification, overflow handling, word wrapping, and tab width for precise visual alignment.
- Tree View Visualizers - The library applies visual themes to tree branches and connecting guide lines to ensure that nested data hierarchies remain easy to follow and visually distinct for the user.