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