feat: add JSON output to validate command (12.10)#391
Merged
Conversation
af4ae57 to
245b429
Compare
Closes #390 - Add ValidateDetailsData DTO with from_result() constructor (src/presentation/cli/views/commands/validate/view_data/validate_details.rs) - Add JsonView: renders JSON via serde_json with fallback on error (src/presentation/cli/views/commands/validate/views/json_view.rs) - Add TextView: renders human-readable text preserving existing output (src/presentation/cli/views/commands/validate/views/text_view.rs) - Add output_format param to ValidateCommandController::execute() - Dispatch to JsonView/TextView in complete_workflow() via Strategy Pattern - Router: pass context.output_format() to controller - Update docs/user-guide/commands/validate.md with JSON section Text output is identical to pre-change output (verified manually). JSON output fields: environment_name, config_file, provider, is_valid, has_prometheus, has_grafana, has_https, has_backup
245b429 to
659870e
Compare
Member
Author
|
ACK 659870e |
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
Closes #390 — Part of EPIC #348 (roadmap task 12.10).
Adds JSON output format support to the
validatecommand. When--output-format jsonis passed, the command outputs a machine-readable JSON object to stdout. The existing human-readable text output is fully preserved.Changes
New files
src/presentation/cli/views/commands/validate/mod.rs— module declarationsrc/presentation/cli/views/commands/validate/view_data/validate_details.rs—ValidateDetailsDataDTO withfrom_result(&Path, &ValidationResult)constructorsrc/presentation/cli/views/commands/validate/views/json_view.rs—JsonViewwith unit testssrc/presentation/cli/views/commands/validate/views/text_view.rs—TextViewwith unit testsModified files
src/presentation/cli/controllers/validate/handler.rs— addoutput_format: OutputFormatparam toexecute(), refactorcomplete_workflow()to dispatch toTextView/JsonViewsrc/presentation/cli/dispatch/router.rs— passcontext.output_format()to controllersrc/presentation/cli/views/commands/mod.rs— registerpub mod validatedocs/user-guide/commands/validate.md— add JSON output sectionJSON Output
cargo run -- validate --env-file envs/lxd-local-example.json --output-format json 2>/dev/null{ "environment_name": "lxd-local-example", "config_file": "envs/lxd-local-example.json", "provider": "lxd", "is_valid": true, "has_prometheus": true, "has_grafana": true, "has_https": false, "has_backup": false }Text Output (unchanged)
cargo run -- validate --env-file envs/lxd-local-example.json 2>&1Quality Checks
cargo run --bin linter allpasses (stable + nightly)cargo machete— no unused dependenciescargo test— 417 tests pass, 0 failuresRelated
validatecommand (12.10) #390docs/issues/390-add-json-output-to-validate-command.md