Skip to main content

Crate pimalaya_cli

Crate pimalaya_cli 

Source
Expand description

Shared building blocks for the Pimalaya command-line tools. Published for internal Pimalaya usage: the API follows the needs of its consumers (himalaya, neverest, cardamum, calendula and friends) and may change without notice. Third parties should treat it as private; the io-* protocol crates and pimalaya-stream are the supported surface.

This crate factors out the pieces every Pimalaya CLI would otherwise reimplement: argument parsing glue, output rendering, logging and interactive prompts. Each piece sits behind its own cargo feature, so a binary pulls in only what it uses.

Unlike the io-* protocol libraries this crate is deliberately std: it exists to talk to a terminal, a filesystem and a human, so it never targets no_std.

The clap module wires shared arguments and the completion, manual and JSON Schema commands into a binary’s parser. The printer and error modules render command output, events and failures to stdout, the output module holds the shapes every binary shares (bytes, pages), and the log module initializes the logger.

Text output is plain text: no border, no colour, nothing sized to the terminal. The fields module lays a record out as aligned Label: value lines, the columns module a list of short rows as aligned columns under a header, the listing module frames a list with the fields placing it and the errors of its items, the account module prints the accounts and whether their backends answer, the capability module what an account serves, the records module a list of wide items the way git log prints commits, and the sanitize module defuses untrusted text before any of them prints it.

A binary has no setup wizard: on a first run, the welcome module tells a person which configuration file is missing and prints the commands creating it from the sample shipped next to the binary, then the first command to run. The shell module quotes such commands for a paste.

A binary keeping one account open across commands runs a session over its stdin: the repl module reads one command per line with the binary’s own grammar, the mcp module answers Model Context Protocol requests, its tools derived from that grammar or written by hand, and the session module keeps the commands they run off stdin.

The prompt and spinner modules handle interactive input and progress, and the signal module the termination signals a long-lived command stops cleanly on. The build module exposes helpers for build scripts.

Modules§

accountterminal
Account
buildbuild
Helpers for binary build scripts.
capabilityterminal
Capability
clapterminal
Shared clap building blocks: arguments, value parsers, the ready-made completion and manual generation commands, and parse, the entry point honouring the exit contract on a refused command line.
columnsterminal
Text lists printed as aligned columns.
errorterminal
Command failure reporting to stdout.
fieldsterminal
Text records printed as aligned fields.
listingterminal
Listing
logterminal
Logger initialization from the shared log flags.
mcpmcp
A Model Context Protocol server over stdio: the JSON-RPC answers every server gives alike, and the tool results built from what a command prints.
outputterminal
Output shapes shared by every binary.
printerterminal
Command output rendering to stdout.
promptprompt
Interactive prompt helpers wrapping the inquire crate.
recordsterminal
Text lists printed as records.
replrepl
A read-eval-print loop over stdin, running a binary’s own commands against what a session keeps open.
sanitizeterminal
Untrusted text made safe to print on a terminal.
sessionmcp or repl
The stdin of a session.
shellterminal
Commands printed for a person to paste into a shell.
signalsignal
Termination signals: SIGINT, SIGTERM and SIGHUP, Ctrl-C and Ctrl-Break on Windows.
spinnerspinner
Lightweight terminal spinner built on crossterm.
welcometerminal
The welcome a person meets on a first run.

Macros§

footerterminal
Builds the –help footer, with link to bug tracker and sponsor.
long_versionterminal
Builds the long version string (version, enabled features, build target and git revision) for a binary’s --version output.