Skip to content

feat: add JSON output to destroy command (#386) - #387

Merged
josecelano merged 4 commits into
mainfrom
386-add-json-output-to-destroy-command
Feb 26, 2026
Merged

josecelano merged 4 commits into
mainfrom
386-add-json-output-to-destroy-command

Conversation

@josecelano

Copy link
Copy Markdown
Member

Closes #386

Summary

Adds --output-format json support to the destroy command, consistent with the JSON output already available in configure, release, and test commands (part of EPIC #348).

Changes

Feature

  • DestroyDetailsData DTO — presentation-layer data transfer object with From<&Environment<Destroyed>> conversion; instance_ip is Option<IpAddr> to handle environments destroyed before provisioning
  • JsonView — renders DestroyDetailsData as pretty-printed JSON via serde_json
  • TextView — renders DestroyDetailsData as the existing human-readable format, with purge hint gated behind text-only output
  • Controller — DestroyCommandController::execute now accepts OutputFormat and dispatches to the appropriate view using the Strategy Pattern
  • Router — passes context.output_format() to the destroy controller

JSON output shape

{
  "environment_name": "my-environment",
  "instance_name": "torrust-tracker-vm-my-environment",
  "provider": "lxd",
  "state": "Destroyed",
  "instance_ip": "10.140.190.39",
  "created_at": "2026-02-26T17:25:19.775061743Z"
}

instance_ip is null when the environment was destroyed before being provisioned.

Documentation

  • Updated docs/user-guide/commands/destroy.md with an Output Formats section (text + JSON examples, JSON fields reference table)
  • Updated docs/issues/386-add-json-output-to-destroy-command.md implementation checklist

Skills (bonus)

Two new agent skills added to .github/skills/usage/operations/:

  • check-system-dependencies — how to use dependency-installer check to verify all required tools are present
  • install-system-dependencies — how to use dependency-installer install to set up a machine for the first time

Both skills are registered in AGENTS.md.

Testing

  • All 412 unit/integration tests pass (cargo test)
  • All linters pass (cargo run --bin linter all)
  • Manually verified JSON output end-to-end:
    cargo run -- create environment --env-file envs/lxd-local-example.json
    cargo run -- destroy lxd-local-example --output-format json
    Output:
    {
      "environment_name": "lxd-local-example",
      "instance_name": "torrust-tracker-vm-lxd-local-example",
      "provider": "lxd",
      "state": "Destroyed",
      "instance_ip": null,
      "created_at": "2026-02-26T17:25:19.775061743Z"
    }

- Add JsonView and TextView rendering strategies in presentation layer
- Add DestroyDetailsData DTO with From<&Environment<Destroyed>> conversion
- Update DestroyCommandController::execute to accept OutputFormat
- Route --output-format flag from CLI context to destroy controller
- Update docs/user-guide/commands/destroy.md with Output Formats section
Add .github/skills/usage/operations/check-system-dependencies/skill.md
with instructions for using the dependency-installer package to
verify system requirements (OpenTofu, Ansible, LXD, cargo-machete).

Register the new skill in the AGENTS.md skills table.
Add .github/skills/usage/operations/install-system-dependencies/skill.md
with instructions for installing required system dependencies
(OpenTofu, Ansible, LXD, cargo-machete) using the built-in
dependency-installer package.

Register the new skill in the AGENTS.md skills table.
@josecelano josecelano self-assigned this Feb 26, 2026
@josecelano

Copy link
Copy Markdown
Member Author

ACK 904e36f

@josecelano
josecelano merged commit 9a886cb into main Feb 26, 2026
33 checks passed
josecelano added a commit that referenced this pull request Feb 26, 2026
- 12.8 Add JSON output to test command - Issue #380, PR #383
- 12.9 Add JSON output to destroy command - Issue #386, PR #387
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add JSON output to destroy command (12.9)

1 participant