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 configure command [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_at is the single lifecycle timestamp from the domain model. There is no separate configured_at field. 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() returns String (not Result) — serialization errors handled inline via unwrap_or_else fallback JSON
- No
OutputFormatting error variant needed in ConfigureSubcommandError
display_configure_results() uses a match output_format { Text => ..., Json => ... } Strategy Pattern
- Router extracts
output_format via context.output_format() and passes it to execute()
Key files to create/modify:
src/presentation/views/commands/configure/ — new module (mirrors provision/ with view_data/ subdir)
src/presentation/controllers/configure/handler.rs — add output_format param and display_configure_results()
src/presentation/dispatch/router.rs — pass output_format to execute()
Acceptance Criteria
Related
Overview
Implement JSON output format support for the
configurecommand (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:
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" }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 JSONOutputFormattingerror variant needed inConfigureSubcommandErrordisplay_configure_results()uses amatch output_format { Text => ..., Json => ... }Strategy Patternoutput_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 stdoutenvironment_name,state,created_at,instance_ipconfigure my-env(default text) continues to work unchangedJsonViewandTextViewhave unit tests followingit_should_...naming conventionprintln!/eprintln!— all output viaUserOutput./scripts/pre-commit.shRelated
release(task 12.7)