Expand description
§rainier-console
The console kernel: an Arguments parser, a Command contract, and the
Console that dispatches between them — Rainier’s command-line entry
point.
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)
}
}
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.
Re-exports§
pub use arguments::Arguments;pub use console::exit;pub use console::Command;pub use console::Console;
Modules§
- arguments
- Parsing a command line into
Arguments. - console
- The console kernel —
CommandandConsole. - io
- Talking to whoever is running the command —
table,ask,secret,confirm,confirm_by_typing.