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 contract;
16mod diagnostic;
17mod dispatch;
18mod handler;
19mod hooks;
20mod stream;
21pub mod verify;
22pub use artifact::{Artifact, ArtifactDestination, ArtifactReceipt, ArtifactRun};
23pub use contract::{ContractSurface, Envelope};
24pub use diagnostic::{Diagnostic, DiagnosticKind, DiagnosticPosition, DiagnosticRange, Severity};
25pub use dispatch::{
26    extract_command_path, get_deepest_matches, has_subcommand, insert_default_command,
27    path_to_string, string_to_path,
28};
29pub use handler::{
30    AppFailure, CommandContext, DispatchResult, ExitStatus, Extensions, ExternalFailure, FnHandler,
31    Handler, HandlerResult, IntoHandlerResult, InvalidAppStatus, InvalidExternalStatus, Output,
32    OutputKind, RunError, RunErrorKind, RunOutput, SimpleFnHandler, SuccessKind,
33};
34pub use hooks::{
35    ArtifactOutput, HookError, HookPhase, Hooks, PostDispatchFn, PostOutputFn, PreDispatchFn,
36    RenderedOutput, TextOutput,
37};
38pub use stream::{EntryStream, StreamCapture, StreamError, StreamSink};