rainier_console/lib.rs
1//! # rainier-console
2//!
3//! The console kernel: an [`Arguments`] parser, a [`Command`] contract, and the
4//! [`Console`] that dispatches between them — Rainier's command-line entry
5//! point.
6//!
7//! ```
8//! use rainier_console::{Arguments, Command, Console};
9//! use rainier_container::Application;
10//! use rainier_support::Result;
11//!
12//! struct Inspire;
13//!
14//! #[async_trait::async_trait]
15//! impl Command for Inspire {
16//! fn name(&self) -> &str { "inspire" }
17//! fn description(&self) -> &str { "Print an inspiring quote" }
18//!
19//! async fn handle(&self, _args: &Arguments, _app: &Application) -> Result<i32> {
20//! println!("Simplicity is the ultimate sophistication.");
21//! Ok(0)
22//! }
23//! }
24//!
25//! # #[tokio::main] async fn main() {
26//! let console = Console::new("rainier").register(Inspire);
27//! let app = Application::new(".");
28//!
29//! assert_eq!(console.run_argv(&app, ["inspire"]).await, 0);
30//! # }
31//! ```
32//!
33//! This crate deliberately knows nothing about routing, queues or databases —
34//! it depends only on the container. The concrete commands (`route:list`,
35//! `serve`, `migrate`, `queue:work`) live in the `rainier` crate, which already
36//! depends on everything they need. That keeps a console usable in an
37//! application that has no HTTP layer at all.
38
39#![deny(missing_docs)]
40#![deny(rustdoc::broken_intra_doc_links)]
41
42pub mod arguments;
43pub mod console;
44pub mod io;
45
46pub use arguments::Arguments;
47pub use console::{exit, Command, Console};
48
49// Re-exported so command implementations get the attribute macro without
50// adding the dependency themselves.
51pub use async_trait::async_trait;