torrust_tracker_deployer_lib/presentation/cli/controllers/create/mod.rs
1//! Create Command Presentation Module
2//!
3//! This module implements the CLI presentation layer for the create command,
4//! handling Figment integration for configuration file parsing, argument
5//! processing, and user interaction.
6//!
7//! ## Architecture
8//!
9//! The create command presentation layer follows the existing patterns from
10//! the destroy command and integrates with the application layer's
11//! `CreateCommandHandler`. Figment is used as a delivery mechanism and stays
12//! in the presentation layer following DDD boundaries.
13//!
14//! ## Components
15//!
16//! - `router` - Main command router routing between subcommands
17//! - `subcommands` - Individual subcommand implementations (environment, template)
18//! - `environment` - Contains environment creation logic, error types, and config loading
19//! - `errors` - Unified error types for all create subcommands
20//!
21//! ## Usage Example
22//!
23//! ```ignore
24//! use std::path::{Path, PathBuf};
25//! use std::sync::{Arc, Mutex};
26//! use torrust_tracker_deployer_lib::presentation::cli::input::cli::commands::CreateAction;
27//! use torrust_tracker_deployer_lib::presentation::cli::controllers::create;
28//! use torrust_tracker_deployer_lib::presentation::cli::dispatch::ExecutionContext;
29//!
30//! # #[tokio::main]
31//! # async fn main() {
32//! let action = CreateAction::Environment {
33//! env_file: PathBuf::from("config/environment.json")
34//! };
35//! // Note: ExecutionContext would be provided by the application bootstrap
36//! # let context = todo!(); // Mock for documentation example
37//!
38//! if let Err(e) = create::route_command(action, Path::new("."), &context).await {
39//! eprintln!("Create failed: {e}");
40//! eprintln!("\n{}", e.help());
41//! }
42//! # }
43//! ```
44
45pub mod errors;
46pub mod router;
47pub mod subcommands;
48
49#[cfg(test)]
50mod tests;
51
52// Re-export commonly used types for convenience
53pub use errors::CreateCommandError;
54pub use router::route_command;
55pub use subcommands::environment::{ConfigFormat, ConfigLoader, CreateEnvironmentCommandError};
56pub use subcommands::schema::CreateSchemaCommandError;
57pub use subcommands::template::CreateEnvironmentTemplateCommandError;