Expand description
Command dispatch and orchestration for clap-based CLIs.
Routes parsed ArgMatches to a Handler, running pre-dispatch, handler,
post-dispatch, and post-output hooks around it, and returns typed
HandlerResult data — presentation stays with the consuming framework.
A handler adapter takes (&ArgMatches, &CommandContext) and returns
serializable data, so application logic stays reusable outside a CLI. The
third parameter of Handler::handle is the typed results channel of
[results]; a batch command sets Handler::Event to NoEvents and
ignores it, and a command that produces its result while it runs takes the
channel as a third closure parameter through EventsFnHandler.
CommandContext carries two kinds of injected state: app_state is
immutable and app-lifetime (database, config, API clients), built once
and shared via Rc; extensions is mutable and per-request, set by
pre-dispatch hooks for things like a resolved user session.
Re-exports§
pub use artifact::Artifact;pub use artifact::ArtifactDestination;pub use artifact::ArtifactReceipt;pub use artifact::ArtifactRun;
Modules§
Structs§
- AppFailure
- Artifact
Output - Command
Context - Diagnostic
- Diagnostic
Position - Diagnostic
Range - Envelope
- Events
FnHandler - The adapter behind a three-argument closure, whose third parameter is the
command’s typed results channel, so
Eventis the closure’s event type. - Exit
Status - Extensions
- External
Failure - FnHandler
- Hook
Error - Hooks
- Invalid
AppStatus - Invalid
External Status - Results
- The handler’s channel for the values a command produces while it runs.
- RunError
- RunOutput
- RunRecorder
- Retains the run’s result values and its delivery decision.
- Simple
FnHandler - Stream
Capture - Stream
Sink - Text
Output
Enums§
- Delivery
- Where the run’s rendered bytes went.
Pagercarries the shell word list the environment named, decided without starting the pager. - Diagnostic
Kind - Dispatch
Result - Emit
Error - Hook
Phase - NoEvents
- The event type of a command that emits none: uninhabited, so
emithas no argument that can be constructed. - Output
- Output
Kind - Rendered
Output - RunError
Kind - Severity
- Success
Kind - Summary
- What a command that declares events returns once the events are done: they already carried the run’s results, so a payload has nowhere left to go.
Traits§
- Contract
Surface - Event
Sink - The representation’s destination for one emitted event.
- Handler
- Handler
Outcome - What
Handler::handlemay return, tied to the command’s event type:Output<T>is an outcome only forNoEvents, so a command that declares events hasSummary<T>and no payload variant to return. - Into
Handler Result - Into
Summary Result
Functions§
- emits_
events - Whether a command whose
Handler::EventisEproduces its result while it runs: false forNoEventsand true for every other event type. - extract_
command_ path - get_
deepest_ matches - has_
subcommand - insert_
default_ command - path_
to_ string - string_
to_ path