Expand description
Views for Create Command
This module contains view components for the create command, responsible for formatting and rendering output to users.
§Architecture
This module follows the Strategy Pattern for rendering:
EnvironmentDetailsData: The data DTO passed to all viewsTextView: Renders human-readable text outputJsonView: Renders machine-readable JSON output
§Structure
view_data/: Data structures (DTOs) prepared for view renderingviews/: View implementations (text, JSON, etc.)
§SOLID Principles
- Single Responsibility: Each view has one job - render in its format
- Open/Closed: Add new formats by creating new view files, not modifying existing ones
- Strategy Pattern: Different rendering strategies for the same data
§Adding New Formats
To add a new output format (e.g., XML, YAML, CSV):
- Create a new file in
views/:xml_view.rs,yaml_view.rs, etc. - Implement the view with
render(data: &EnvironmentDetailsData) -> Result<String, Error> - Export it from the
viewsmodule - No need to modify existing views or the DTO
Re-exports§
pub use view_data::EnvironmentDetailsData;pub use views::JsonView;pub use views::TextView;