Skip to main content

standout_dispatch/
lib.rs

1//! Command dispatch and orchestration for clap-based CLIs.
2//!
3//! Routes parsed `ArgMatches` to a [`Handler`], running pre-dispatch, handler,
4//! post-dispatch, and post-output hooks around it, and returns typed
5//! [`HandlerResult`] data — presentation stays with the consuming framework.
6//! A handler adapter takes `(&ArgMatches, &CommandContext)` and returns
7//! serializable data, so application logic stays reusable outside a CLI.
8//!
9//! [`CommandContext`] carries two kinds of injected state: `app_state` is
10//! immutable and app-lifetime (database, config, API clients), built once
11//! and shared via `Rc`; `extensions` is mutable and per-request, set by
12//! pre-dispatch hooks for things like a resolved user session.
13
14pub mod artifact;
15mod dispatch;
16mod handler;
17mod hooks;
18pub mod verify;
19pub use artifact::{Artifact, ArtifactDestination, ArtifactReceipt, ArtifactRun};
20pub use dispatch::{
21    extract_command_path, get_deepest_matches, has_subcommand, insert_default_command,
22    path_to_string, string_to_path,
23};
24pub use handler::{
25    CommandContext, DispatchResult, ExitStatus, Extensions, ExternalFailure, FnHandler, Handler,
26    HandlerResult, IntoHandlerResult, InvalidExternalStatus, Output, OutputKind, RunError,
27    RunErrorKind, RunOutput, SimpleFnHandler, SuccessKind,
28};
29pub use hooks::{
30    ArtifactOutput, HookError, HookPhase, Hooks, PostDispatchFn, PostOutputFn, PreDispatchFn,
31    RenderedOutput, TextOutput,
32};