Skip to main content

torrust_tracker_deployer_lib/presentation/cli/controllers/configure/
mod.rs

1//! Configure Command Presentation Module
2//!
3//! This module implements the CLI presentation layer for the configure command,
4//! handling argument processing and user interaction.
5//!
6//! ## Architecture
7//!
8//! The configure command presentation layer follows the DDD pattern, orchestrating
9//! the application layer's `ConfigureCommandHandler` 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//! ### Basic Usage
20//!
21//! ```ignore
22//! use std::path::Path;
23//! use std::sync::Arc;
24//! use torrust_tracker_deployer_lib::bootstrap::Container;
25//! use torrust_tracker_deployer_lib::presentation::cli::dispatch::ExecutionContext;
26//! use torrust_tracker_deployer_lib::presentation::cli::controllers::configure;
27//! use torrust_tracker_deployer_lib::presentation::cli::views::VerbosityLevel;
28//!
29//! let container = Container::new(VerbosityLevel::Normal, Path::new("."));
30//! let context = ExecutionContext::new(Arc::new(container), global_args);
31//!
32//! // Call the configure handler
33//! let result = context
34//!     .container()
35//!     .create_configure_controller()
36//!     .execute("my-environment");
37//! ```
38//!
39//! ### Direct Usage (For Testing)
40//!
41//! ```ignore
42//! use std::path::Path;
43//! use std::sync::Arc;
44//! use torrust_tracker_deployer_lib::bootstrap::Container;
45//! use torrust_tracker_deployer_lib::presentation::cli::dispatch::ExecutionContext;
46//! use torrust_tracker_deployer_lib::presentation::cli::controllers::configure;
47//! use torrust_tracker_deployer_lib::presentation::cli::views::VerbosityLevel;
48//!
49//! let container = Container::new(VerbosityLevel::Normal, Path::new("."));
50//! let context = ExecutionContext::new(Arc::new(container), global_args);
51//!
52//! if let Err(e) = context
53//!     .container()
54//!     .create_configure_controller()
55//!     .execute("test-env")
56//! {
57//!     eprintln!("Configure failed: {e}");
58//!     eprintln!("\n{}", e.help());
59//! }
60//! ```
61//!
62//! ## Direct Usage (For Testing)
63//!
64//! ```ignore
65//! use std::path::{Path, PathBuf};
66//! use std::sync::Arc;
67//! use std::time::Duration;
68//! use parking_lot::ReentrantMutex;
69//! use std::cell::RefCell;
70//! use torrust_tracker_deployer_lib::presentation::cli::controllers::configure::handler::ConfigureCommandController;
71//! use torrust_tracker_deployer_lib::presentation::cli::views::{UserOutput, VerbosityLevel};
72//! use torrust_tracker_deployer_lib::infrastructure::persistence::file_repository_factory::FileRepositoryFactory;
73//! use torrust_tracker_deployer_lib::shared::clock::SystemClock;
74//!
75//! # #[tokio::main]
76//! # async fn main() {
77//! let output = Arc::new(ReentrantMutex::new(RefCell::new(UserOutput::new(VerbosityLevel::Normal))));
78//! let data_dir = PathBuf::from("./data");
79//! let file_repository_factory = FileRepositoryFactory::new(Duration::from_secs(30));
80//! let repository = file_repository_factory.create(data_dir);
81//! let clock = Arc::new(SystemClock);
82//! if let Err(e) = ConfigureCommandController::new(repository, clock, output).execute("test-env") {
83//!     eprintln!("Configure failed: {e}");
84//!     eprintln!("\n{}", e.help());
85//! }
86//! # }
87//! ```
88
89pub mod errors;
90pub mod handler;
91pub use handler::ConfigureCommandController;
92
93#[cfg(test)]
94mod tests;
95
96// Re-export commonly used types for convenience
97pub use errors::ConfigureSubcommandError;