Merged
Conversation
Implement JSON output format for the run command following the Strategy Pattern established in #349, #352, and #355. Changes: - Add TextView and JsonView in src/presentation/views/commands/run/ - Update RunCommandController to accept output_format parameter - Update router to pass output_format from ExecutionContext - Update all unit tests to pass OutputFormat::Text - Add JSON output documentation to docs/user-guide/commands/run.md Implementation: - TextView: Refactors existing text output using shared CompactServiceUrlsView and DnsHintView - JsonView: Serializes ServiceInfo and GrafanaInfo to JSON with environment_name and state - Controller: Uses Strategy Pattern to select view based on output_format - Router: Extracts output_format from context and passes to controller Testing: - 4 unit tests for TextView (basic output, grafana, DNS hints, tip) - 4 unit tests for JsonView (basic JSON, grafana, valid parsing, all fields) - All existing tests updated to pass OutputFormat::Text Documentation: - Add JSON output section with structure, examples, and automation use cases - Document all JSON fields with descriptions - Add jq examples for common automation tasks
Member
Author
|
ACK 81f925a |
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.
Description
Implements JSON output format for the
runcommand following the Strategy Pattern established in #349, #352, and #355.Closes #357
Changes
Implementation
src/presentation/views/commands/run/text_view.rs): Refactors existing text output logic using shared components (CompactServiceUrlsViewandDnsHintView)src/presentation/views/commands/run/json_view.rs): SerializesServiceInfoandGrafanaInfoto JSON withenvironment_nameand state wrapperoutput_formatparameter and use Strategy Pattern to select appropriate viewoutput_formatfromExecutionContextto controllerTesting
OutputFormat::TextDocumentation
docs/user-guide/commands/run.mdjqexamplesArchitecture
Follows the established pattern from previous implementations:
output_formatoutput_formatfrom context and passes to controllerExample Usage
Text Output (default)
JSON Output
torrust-tracker-deployer run my-env --output-format json # Or short form: torrust-tracker-deployer run my-env -o jsonJSON with jq
Verification
Related Issues