Expand description
Library surface for user binaries to host umbral’s management subcommands.
umbral-cli ships as two artefacts. The library (this crate) exposes
dispatch — the entry point user binaries call to gain the
serve / migrate / makemigrations / inspectdb /
dumpdata / loaddata subcommands. The binary (umbral) ships as
the global scaffolding tool installed via cargo install umbral-cli, and handles startproject / startapp from outside
any project.
§Quickstart
In your project’s src/main.rs:
ⓘ
use umbral::prelude::*;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
tracing_subscriber::fmt::init();
let settings = Settings::from_env()?;
let pool = umbral::db::connect(&settings.database_url).await?;
let app = App::builder()
.settings(settings)
.database("default", pool)
.model::<Article>()
.build()?;
umbral_cli::dispatch(app).await
}Then:
cargo run -- migrate
cargo run -- serve
cargo run -- makemigrationsThe subcommands run against the published ambient state (pool,
model registry) that App::build set up, so they see every model
and plugin the user wired into the builder.
Modules§
- scaffold
- Project + plugin scaffolding.
Functions§
- dispatch
- Parse argv and run the requested management subcommand against the
passed-in App. The user binary’s
main.rscalls this after building its App — see the module-level docs for the pattern. - dispatch_
with_ argv - Same as
dispatchbut argv is passed explicitly instead of read from the process. Lets tests exercise the routing without spawning a subprocess. User code should calldispatch(which readsstd::env::args_os()and delegates here).