Expand description
sparcli is a lightweight, cross-platform toolkit for styled command-line
output and interactive input widgets.
It renders directly to the terminal via crossterm (no ratatui
dependency) but mirrors ratatui’s familiar vocabulary (Style,
Color, Span, Line, Text). Output widgets implement
Renderable and can be printed inline; input widgets run small,
self-contained prompt loops.
The base crate stays small; heavier features live behind cargo features
(markup, fuzzy, pager).
§Examples
Build a styled panel and render it to a string (no terminal required), which is exactly how the output widgets are tested:
use sparcli::{Color, Panel, Renderable, Style, Title};
let panel = Panel::new("Build succeeded.")
.title(Title::new("Status"))
.border_style(Style::new().fg(Color::Green));
let out = panel.render(40);
assert!(out.plain().contains("Build succeeded."));In a real program you would print it straight to the terminal with
panel.print()? instead of rendering to a string.
Modules§
- event
- Keyboard events and the dependency-injected event source (for headless testing and custom input backends).
- markup
- Rich-style inline markup parsing (
[bold red]text[/]). - prelude
- Commonly used types, re-exported for
use sparcli::prelude::*;. - shortcut
- Keyboard shortcuts and their footer-hint / help-overlay rendering.
- terminal
- Terminal capability and size detection.
- validate
- Value validators and character filters for text prompts.
- width
- Unicode-aware display-width helpers (width, ANSI stripping, wrap, truncate).
Structs§
- Alert
- A bordered, pre-styled status message.
- Attribute
- Text attribute flags (bold, dim, italic, …), combinable with
|. - Badge
- A small inline token with configurable caps and style.
- Cell
- A single table cell.
- Column
- A single table column definition.
- Columns
- A horizontal arrangement of rendered blocks.
- Confirm
- A yes/no confirmation prompt.
- Date
- A calendar date (proleptic Gregorian).
- Date
Picker - A month-grid date picker prompt.
- Diff
- A unified diff between two texts.
- Edges
- Box-model spacing (padding or margin) in terminal cells.
- Fuzzy
Select - An inline fuzzy-select prompt.
- History
- A bounded list of past input lines, optionally backed by a file.
- KeyValue
- A list of aligned key-value pairs.
- Line
- One visual line: a sequence of
Spans. - List
- A bulleted or ordered list.
- Live
- A live display that redraws content in place.
- Multi
Progress - A group of progress bars rendered as one block and updated in place.
- Number
Input - A numeric input prompt with optional calculator expressions.
- Pager
- Pages content through an external pager.
- Panel
- A bordered panel around rich content.
- Password
Input - A masked password input prompt.
- Progress
Bar - A configurable progress bar.
- Rendered
- A fully laid-out block of styled lines, ready to print or compose.
- Rule
- A horizontal divider line, optionally labelled with a title.
- Select
- A scrollable selection list (single or multi).
- Shortcut
- A bound shortcut: a key, a caller-defined id and a footer label.
- Span
- A run of text sharing one
Styleand an optional hyperlink. - Spinner
- An animated, single-line spinner with a label.
- Style
- A foreground/background color pair plus text attributes.
- Table
- A data table.
- Text
- Multi-line rich text.
- Text
Input - A single-line text input prompt.
- Textarea
- A multi-line text input prompt.
- Theme
- Visual defaults applied across input and output.
- Thresholds
- Threshold-based fill colors keyed on the completion ratio.
- Title
- A framed title, e.g. on a panel, rule or table.
- Tree
- A tree of
TreeNodes rendered with connector glyphs. - Tree
Node - A node in a
Tree.
Enums§
- Alert
Kind - The severity/kind of an
Alert. - Align
- Horizontal alignment.
- Border
Type - The visual style of a border.
- Color
- A terminal color.
- Marker
- The marker style for list items.
- Outcome
- The result of running an interactive prompt.
- Position
- Where a title sits relative to its frame.
- Progress
Style - The visual style of the filled/empty bar cells.
- Sparcli
Error - Errors that can occur while rendering output or running input prompts.
- Spinner
Style - The animation style of a spinner.
- VAlign
- Vertical alignment.
Traits§
- Renderable
- Anything that can be laid out into a
Renderedand printed.
Functions§
- edit_
file - Opens an external editor on
path, blocking until it exits. - set_
theme - Replaces the process-wide theme.
- theme
- Returns a clone of the current theme.