feat: Add JSON output format to configure command#373
Merged
Conversation
- Add ConfigureDetailsData DTO for presentation layer - Implement JsonView and TextView for configure command - Update ConfigureCommandController to accept output_format parameter - Add display_configure_results() method using Strategy Pattern - Update router to pass output_format from context - Add comprehensive unit tests for views and controller - Follow list command pattern (JsonView returns String with inline error handling) Closes #371
- Added assert_contains_all() helper to text_view.rs tests - Replaced 13 individual assert! calls with single helper call - Improved readability and maintainability - Added assert_json_fields_eq() and assert_json_has_fields() helpers to json_view.rs tests - Replaced 6 assert_eq! calls with assert_json_fields_eq() - Replaced 6 assert! calls with assert_json_has_fields() - Better error messages showing expected vs actual values
- Added Phase 3: Avoiding Duplicate Code - Explains DRY principle for test fixtures and setup - Shows how to decouple helpers by adding parameters - Added Step 6: Create assertion helpers - Demonstrates extracting repetitive assertions into reusable helpers - Includes before/after examples from configure view tests - Highlights benefits: readability, maintainability, better error messages
…ciples - Added Beck's Four Rules in priority order: 1. Passes the tests - code must work as intended 2. Reveals intention - code should express purpose clearly 3. No duplication - apply DRY/Once and Only Once 4. Fewest elements - remove anything that doesn't serve prior rules - Included reference to Martin Fowler's article - Noted that rules feed off each other and empathy wins over metrics
- Fixed clippy::uninlined_format_args warnings in test helpers - Updated assert_json_fields_eq() in json_view.rs - Updated assert_json_has_fields() in json_view.rs - Updated assert_contains_all() in text_view.rs - All linters now pass successfully
Member
Author
|
ACK 831f177 |
14 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Adds JSON output format support to the
configurecommand, implementing roadmap task 12.6 as part of Phase 2 of the JSON output epic (#348).Changes
New View Module
src/presentation/views/commands/configure/module with DDD structureConfigureDetailsDataDTO for presentation layerprovision/module pattern withview_data/andviews/subdirectoriesViews Implementation
Stringwith inline error handling (list command pattern)instance_ipgracefullyController Updates
output_format: OutputFormatparameter toConfigureCommandController::execute()display_configure_results()method using Strategy Patternoutput_formatfrom contextTesting
JSON Output Example
{ "environment_name": "my-env", "instance_name": "torrust-tracker-vm-my-env", "provider": "lxd", "state": "Configured", "instance_ip": "10.140.190.101", "created_at": "2026-02-23T08:26:06.789141249Z" }Usage
Architecture
UserOutputmethods (no directprintln!)Related
configurecommand #371listcommand (most recent pattern),provisioncommand (module structure)Closes #371