-
Notifications
You must be signed in to change notification settings - Fork 0
Description
Overview
Implement JSON output format support for the configure command (roadmap task 12.6).
This is part of Phase 2 of the JSON output epic (#348), which aims to add JSON output to all remaining commands so that JSON can eventually become the default output format.
Specification
Full implementation specification (goals, architecture, DTO definition, code patterns, acceptance criteria):
docs/issues/371-add-json-output-to-configure-command.md
Roadmap Reference
From docs/roadmap.md - section 12.6:
12.6 Add JSON output to
configurecommand [Issue #371]
- Rationale: Contains the list of installed/configured components (Docker, security updates, firewall) and their status
- Allows automation to verify successful configuration before proceeding to release
Expected JSON Output
{
"environment_name": "my-env",
"instance_name": "torrust-tracker-vm-my-env",
"provider": "lxd",
"state": "Configured",
"instance_ip": "10.140.190.39",
"created_at": "2026-02-20T10:00:00Z"
}Note:
created_atis the single lifecycle timestamp from the domain model. There is no separateconfigured_atfield. The exact schema is specified in the spec file linked above.
Implementation Pattern
Follow the list command pattern from PR #360 (most recent, canonical — not the older provision pattern):
JsonView::render()returnsString(notResult) — serialization errors handled inline viaunwrap_or_elsefallback JSON- No
OutputFormattingerror variant needed inConfigureSubcommandError display_configure_results()uses amatch output_format { Text => ..., Json => ... }Strategy Pattern- Router extracts
output_formatviacontext.output_format()and passes it toexecute()
Key files to create/modify:
src/presentation/views/commands/configure/— new module (mirrorsprovision/withview_data/subdir)src/presentation/controllers/configure/handler.rs— addoutput_formatparam anddisplay_configure_results()src/presentation/dispatch/router.rs— passoutput_formattoexecute()
Acceptance Criteria
-
configure my-env --output-format jsonoutputs valid, parseable JSON to stdout - JSON output contains:
environment_name,state,created_at,instance_ip -
configure my-env(default text) continues to work unchanged -
JsonViewandTextViewhave unit tests followingit_should_...naming convention - No
println!/eprintln!— all output viaUserOutput - Pre-commit checks pass:
./scripts/pre-commit.sh
Related
- Parent Epic: EPIC: Add JSON output format support #348
- Next command after this:
release(task 12.7)