pimalaya_cli/lib.rs
1#![cfg_attr(docsrs, feature(doc_cfg))]
2
3//! Shared building blocks for the Pimalaya command-line tools.
4//! Published for internal Pimalaya usage: the API follows the needs of
5//! its consumers (himalaya, neverest, cardamum, calendula and friends)
6//! and may change without notice. Third parties should treat it as
7//! private; the io-* protocol crates and pimalaya-stream are the
8//! supported surface.
9//!
10//! This crate factors out the pieces every Pimalaya CLI would
11//! otherwise reimplement: argument parsing glue, output rendering,
12//! logging and interactive prompts. Each piece sits behind its own
13//! cargo feature, so a binary pulls in only what it uses.
14//!
15//! Unlike the io-* protocol libraries this crate is deliberately std:
16//! it exists to talk to a terminal, a filesystem and a human, so it
17//! never targets no_std.
18//!
19//! The clap module wires shared arguments and the completion, manual
20//! and JSON Schema commands into a binary's parser. The printer and error
21//! modules render command output, events and failures to stdout, the
22//! output module holds the shapes every binary shares (bytes, pages),
23//! and the log module initializes the logger.
24//!
25//! Text output is plain text: no border, no colour, nothing sized to the
26//! terminal. The fields module lays a record out as aligned `Label: value`
27//! lines, the columns module a list of short rows as aligned columns under
28//! a header, the listing module frames a list with the fields placing it and
29//! the errors of its items, the capability module prints what an account
30//! serves, the records module a list of wide items the way `git log`
31//! prints commits, and the sanitize module defuses untrusted text before
32//! any of them prints it.
33//!
34//! A binary has no setup wizard: on a first run, the welcome module tells
35//! a person which configuration file is missing and prints the commands
36//! creating it from the sample shipped next to the binary, then the first
37//! command to run. The shell module quotes such commands for a paste.
38//!
39//! A binary keeping one account open across commands runs a session over
40//! its stdin: the repl module reads one command per line with the
41//! binary's own grammar, the mcp module answers Model Context Protocol
42//! requests, its tools derived from that grammar or written by hand, and
43//! the session module keeps the commands they run off stdin.
44//!
45//! The prompt and spinner modules handle interactive input and progress,
46//! and the signal module the termination signals a long-lived command
47//! stops cleanly on.
48//! The build module exposes helpers for build scripts.
49
50#[cfg(feature = "build")]
51pub mod build;
52#[cfg(feature = "terminal")]
53pub mod capability;
54#[cfg(feature = "terminal")]
55pub mod clap;
56#[cfg(feature = "terminal")]
57pub mod columns;
58#[cfg(feature = "terminal")]
59pub mod error;
60#[cfg(feature = "terminal")]
61pub mod fields;
62#[cfg(feature = "terminal")]
63pub mod listing;
64#[cfg(feature = "terminal")]
65pub mod log;
66#[cfg(feature = "mcp")]
67pub mod mcp;
68#[cfg(feature = "terminal")]
69pub mod output;
70#[cfg(feature = "terminal")]
71pub mod printer;
72#[cfg(feature = "prompt")]
73pub mod prompt;
74#[cfg(feature = "terminal")]
75pub mod records;
76#[cfg(feature = "repl")]
77pub mod repl;
78#[cfg(feature = "terminal")]
79pub mod sanitize;
80#[cfg(any(feature = "repl", feature = "mcp"))]
81pub mod session;
82#[cfg(feature = "terminal")]
83pub mod shell;
84#[cfg(feature = "signal")]
85pub mod signal;
86#[cfg(feature = "spinner")]
87pub mod spinner;
88#[cfg(feature = "terminal")]
89pub mod welcome;