scriba
Typed CLI output, prompts, and terminal rendering for Rust.
scriba helps you build clean, structured command-line interfaces with composable output primitives, interactive prompts, styled logging, and optional ASCII banners.
Features
- 📄 Multi-format rendering: Plain, Text, Markdown, JSON, JSONL
- 🧱 Typed output blocks and builders
- 💬 Interactive prompts (feature:
prompt) - 🎨 Styled logging (feature:
logger) - 🔤 ASCII banners / figlet rendering (feature:
figlet) - ⚙️ Feature-gated integrations
- 🦀 Ergonomic Rust-first APIs
Installation
[]
= "0.1"
# optional features
= { = "0.2", = ["prompt", "logger", "figlet"] }
Feature Flags
| Feature | Enables |
|---|---|
prompt |
Interactive terminal prompts via inquire |
logger |
Styled stderr logging |
figlet |
ASCII banner rendering |
Quick Start
use ;
Output:
Clean CLI rendering.
Output Formats
Supported render targets:
Format::PlainFormat::TextFormat::MarkdownFormat::JsonFormat::Jsonl
let ui = new.with_format;
Core Output Primitives
All output is composed with Output::new().
Titles and Headings
let output = new
.title
.subtitle
.heading
.paragraph;
Paragraphs, Lines, Lists
let output = new
.paragraph
.line
.list;
Ordered list:
.list
Separators
let output = new
.paragraph
.separator
.paragraph;
Code Blocks
let output = new
.code;
Plain Output
Use when your command should emit one scalar value for scripts or shell pipelines.
use ;
let ui = new.with_format;
let output = new.plain;
ui.print?;
Output:
hello
Supported scalar values:
- string
- number
- boolean
- null
Structured Data
Key / Value Data Map
Use top-level structured fields with .data(...).
let output = new
.data
.data;
Useful for JSON, Markdown summaries, and metadata.
JSON Block
let output = new
.json;
JSON Lines (JSONL)
Use jsonl_record(...) for streaming records or line-delimited events.
use ;
let ui = new.with_format;
let output = new
.jsonl_record
.jsonl_record;
ui.print?;
Output:
If no explicit records are provided, blocks can be emitted as JSONL entries.
Key / Value Blocks
Use for compact metadata sections.
let output = new
.key_value
.key_value;
Markdown:
- -
Text:
project: scriba
env: prod
Sequential calls are grouped automatically.
Definition Lists
Use for glossary-style output or descriptive labels.
let output = new
.definition
.definition;
Text:
Project:
scriba
Environment:
production
Status Messages
Use semantic states for results and summaries.
use ;
let output = new
.status
.status;
Available kinds:
StatusKind::InfoStatusKind::OkStatusKind::WarningStatusKind::Error
Tables
use ;
let table = new;
let output = new
.table;
Indexed Tables
Add row numbers automatically.
let table = new.with_index;
Custom header:
let table = new
.with_index_header;
Prompts (prompt feature)
use Ui;
Confirm
let proceed = ui.confirm?;
Select
use ;
let env = ui.select?;
Multi Select
use ;
let values = ui.multiselect?;
Logger (logger feature)
use Ui;
let ui = new;
ui.logger.info?;
ui.logger.ok?;
ui.logger.warn?;
ui.logger.error?;
ui.logger.detail?;
ui.logger.debug?;
ui.logger.trace?;
ui.logger.kv?;
Figlet (figlet feature)
use figlet;
let banner = render?;
println!;
Custom font:
let banner = render_with_font?;
Built-in fonts include:
standardsmallbigslantsmblockmono12futurewidetermmono9
Design Goals
scriba is built around:
- simple APIs first
- standard types where possible
- composable builders
- feature-gated integrations
- no macros required
Recommended Primitive by Use Case
| Need | Use |
|---|---|
| Single shell value | plain() |
| Human-readable report | headings + paragraphs |
| Metadata | key_value() |
| Glossary / labels | definition() |
| State / result | status() |
| Structured object | data() / json() |
| Event stream | jsonl_record() |
| Tabular data | table() |
| Numbered rows | with_index() |
Roadmap
- richer styling options
- table layout variants
- output streaming
- optional derive macros
License
MIT OR Apache-2.0