rtb_cli/lib.rs
1//! CLI application scaffolding.
2//!
3//! # Entry point
4//!
5//! Downstream tools use [`Application::builder`] to wire their
6//! metadata, version info, optional assets + features, and the
7//! framework installs:
8//!
9//! * a `tracing-subscriber` registry (pretty fmt on TTY, JSON
10//! otherwise or when `--log-format json` is set),
11//! * the `miette` diagnostic + panic hooks (via [`rtb_error::hook`]),
12//! * a [`tokio_util::sync::CancellationToken`] bound to `SIGINT` and
13//! Unix `SIGTERM`,
14//! * clap-based command parsing with built-in subcommands filtered by
15//! the runtime [`rtb_app::features::Features`] set.
16//!
17//! ```ignore
18//! use rtb_cli::prelude::*;
19//!
20//! #[tokio::main]
21//! async fn main() -> miette::Result<()> {
22//! Application::builder()
23//! .metadata(ToolMetadata::builder().name("mytool").summary("a tool").build())
24//! .version(VersionInfo::from_env())
25//! .build()?
26//! .run()
27//! .await
28//! }
29//! ```
30//!
31//! See `docs/development/specs/2026-04-22-rtb-cli-v0.1.md` for the
32//! authoritative contract.
33
34// `deny` (not `forbid`) so submodules registering into
35// `linkme::distributed_slice` (the `credentials` and similar
36// subtrees) can `#![allow(unsafe_code)]` for the
37// `#[link_section]` attribute the macro emits. No hand-rolled
38// `unsafe` blocks exist in this crate.
39#![deny(unsafe_code)]
40
41pub mod application;
42pub mod builtins;
43pub mod config_cmd;
44pub mod credentials;
45pub mod health;
46pub mod init;
47pub mod render;
48pub mod runtime;
49pub mod telemetry;
50
51pub use application::{Application, ApplicationBuilder};
52pub use health::{HealthCheck, HealthReport, HealthStatus};
53pub use init::Initialiser;
54pub use render::{output, OutputMode};
55
56/// Glob-importable convenience prelude for downstream `fn main()`.
57pub mod prelude {
58 pub use crate::application::Application;
59 pub use rtb_app::prelude::*;
60 pub use rtb_error::{Error as RtbError, Result as RtbResult};
61}