Skip to content

The rtb-cli family

Four crates that turn a main() into a command-line tool: a command tree that assembles itself, error rendering, signal handling, and a built-in command suite covering version reporting, diagnostics, configuration, credentials and telemetry consent. Three optional crates add documentation inside the binary, signature-verified self-update, and a Model Context Protocol server.

Part of the phpboyscout Rust toolkit; extracted from rust-tool-base. The four crates share one version line and release together.

use rtb_cli::prelude::*;

#[tokio::main]
async fn main() -> std::process::ExitCode {
    let app = Application::builder()
        .metadata(ToolMetadata::builder().name("mytool").summary("a tool").build())
        .version(rtb_app::version_info!())
        .build();

    match app {
        Ok(app) => app.run_and_exit().await,
        Err(report) => rtb_cli::report_to_exit_code(&report),
    }
}

That gets you version, doctor, init, config, credentials and telemetry without writing any of them.

Start here

If you want to… Go to
Build your first tool on it Build a CLI tool on rtb-cli
Solve one specific problem How-to guides
Look up a flag, a file path or a default Reference
Understand why something works the way it does Explanation
Find out what it deliberately does not do What this family does not do

The four crates

Crate Role Component page
rtb-cli The entry point: Application::builder, clap wiring, and six built-in commands rtb-cli
rtb-docs Documentation inside the binary — TUI browser, local HTTP server, full-text search rtb-docs
rtb-update Signature-verified self-update: select, download, verify, swap rtb-update
rtb-mcp Registered commands exposed as Model Context Protocol tools rtb-mcp

rtb-docs, rtb-update and rtb-mcp each register one command into the same link-time registry rtb-cli reads. Adding one to Cargo.toml and referencing it is all the wiring there is — with one catch.

API reference

Item-level signatures live on docs.rs, generated from source: rtb-cli · rtb-docs · rtb-update · rtb-mcp.

Crates: rtb-cli · rtb-docs · rtb-update · rtb-mcp.

  • rtb-appApp, Command, ToolMetadata, the registries.
  • rtb-error — the diagnostic pipeline this family installs.
  • rtb-config — building the typed configuration the config command inspects.
  • rtb-credentials — the resolver behind the credentials command.
  • rtb-assets — the overlay that carries embedded documentation.
  • rtb-forge — the release providers self-update reads from.

Further reading

The blog carries a curated route through this subject: Rust, and what survived the port collects everything written about it, ordered so you can start at the beginning rather than newest-first.

Ask phpbotscout

phpbotscout

He answers questions about the projects over on the Discord, citing the docs where they already cover it, and offering to raise an issue where they don't. Bring a bug, an idea, or a questionable engineering decision.

Join the Discord