torrust_tracker_deployer_lib/presentation/cli/controllers/purge/mod.rs
1//! Purge Command Presentation Module
2//!
3//! This module implements the CLI presentation layer for the purge command,
4//! handling argument processing and user interaction.
5//!
6//! ## Architecture
7//!
8//! The purge command presentation layer follows the DDD pattern, orchestrating
9//! the application layer's `PurgeCommandHandler` while providing user-friendly
10//! output and error handling.
11//!
12//! ## Components
13//!
14//! - `errors` - Presentation layer error types with `.help()` methods
15//! - `handler` - Main command handler orchestrating the workflow
16//!
17//! ## Usage Example
18//!
19//! ### Via Container (Recommended)
20//!
21//! ```rust
22//! use std::path::Path;
23//! use torrust_tracker_deployer_lib::bootstrap::Container;
24//! use torrust_tracker_deployer_lib::presentation::cli::input::cli::OutputFormat;
25//! use torrust_tracker_deployer_lib::presentation::cli::views::VerbosityLevel;
26//!
27//! # #[tokio::main]
28//! # async fn main() {
29//! let container = Container::new(VerbosityLevel::Normal, Path::new("."));
30//! if let Err(e) = container
31//! .create_purge_controller()
32//! .execute("test-env", false, OutputFormat::Text)
33//! .await
34//! {
35//! eprintln!("Purge failed: {e}");
36//! eprintln!("\n{}", e.help());
37//! }
38//! # }
39//! ```
40//!
41//! ## Direct Usage (For Testing)
42//!
43//! ```rust
44//! use std::path::{Path, PathBuf};
45//! use std::sync::Arc;
46//! use std::time::Duration;
47//! use parking_lot::ReentrantMutex;
48//! use std::cell::RefCell;
49//! use torrust_tracker_deployer_lib::application::command_handlers::purge::handler::PurgeCommandHandler;
50//! use torrust_tracker_deployer_lib::presentation::cli::controllers::purge::handler::PurgeCommandController;
51//! use torrust_tracker_deployer_lib::presentation::cli::input::cli::OutputFormat;
52//! use torrust_tracker_deployer_lib::presentation::cli::views::{UserOutput, VerbosityLevel};
53//! use torrust_tracker_deployer_lib::infrastructure::persistence::file_repository_factory::FileRepositoryFactory;
54//!
55//! # #[tokio::main]
56//! # async fn main() {
57//! let output = Arc::new(ReentrantMutex::new(RefCell::new(UserOutput::new(VerbosityLevel::Normal))));
58//! let data_dir = PathBuf::from("./data");
59//! let file_repository_factory = FileRepositoryFactory::new(Duration::from_secs(30));
60//! let repository = file_repository_factory.create(data_dir.clone());
61//! let handler = PurgeCommandHandler::new(repository, data_dir);
62//! if let Err(e) = PurgeCommandController::new(handler, output).execute("test-env", false, OutputFormat::Text).await {
63//! eprintln!("Purge failed: {e}");
64//! eprintln!("\n{}", e.help());
65//! }
66//! # }
67//! ```
68
69pub mod errors;
70pub mod handler;
71pub use handler::PurgeCommandController;
72
73#[cfg(test)]
74mod tests;
75
76// Re-export commonly used types for convenience
77pub use errors::PurgeSubcommandError;