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