Expand description
Progress reporting interface for command workflows
This module defines the CommandProgressListener trait that enables
application-layer command handlers to report progress to the user interface
without depending on presentation-layer types.
§DDD Layer Placement
- Defined in: Application layer (
src/application/traits/) - Implemented in: Presentation layer (
src/presentation/) - Dependency direction: Presentation → Application (correct)
The trait lives here because it’s a use-case concern: progress reporting is about orchestrating steps in a command workflow, which is the application layer’s responsibility. The presentation layer implements the trait to translate progress events into user-facing output.
§Verbosity Mapping
The listener methods map to verbosity levels (but the listener itself does not know about verbosity — that’s the implementation’s concern):
on_step_started/on_step_completed→ Verbose (-v)on_detail→VeryVerbose(-vv)on_debug→ Debug (-vvv)
The application layer reports everything; the presentation layer filters based on the user’s chosen verbosity level.
§Example
use torrust_tracker_deployer_lib::application::traits::CommandProgressListener;
async fn execute(
&self,
env_name: &EnvironmentName,
listener: Option<&dyn CommandProgressListener>,
) -> Result<(), Error> {
if let Some(l) = listener {
l.on_step_started(1, 3, "Rendering templates");
}
// ... perform step ...
if let Some(l) = listener {
l.on_step_completed(1, "Rendering templates");
}
Ok(())
}Structs§
- Null
Progress Listener - A no-op listener that discards all progress events.
Traits§
- Command
Progress Listener - A listener for reporting command progress to the user interface.