Skip to content

feat: add JSON output to purge command (12.12)#395

Merged
josecelano merged 1 commit into
mainfrom
394-add-json-output-to-purge-command
Feb 27, 2026
Merged

feat: add JSON output to purge command (12.12)#395
josecelano merged 1 commit into
mainfrom
394-add-json-output-to-purge-command

Conversation

@josecelano

Copy link
Copy Markdown
Member

Summary

Implements roadmap task 12.12 — adds --output-format json support to the purge command.
Closes #394.

Changes

New files

  • src/presentation/cli/views/commands/purge/mod.rs — module with re-exports
  • src/presentation/cli/views/commands/purge/view_data/purge_details.rsPurgeDetailsData { environment_name, purged } with from_environment_name() constructor
  • src/presentation/cli/views/commands/purge/views/json_view.rsJsonView::render() → pretty-printed JSON
  • src/presentation/cli/views/commands/purge/views/text_view.rsTextView::render()"Environment '…' purged successfully"

Modified files

  • src/presentation/cli/views/commands/mod.rs — added pub mod purge;
  • src/presentation/cli/controllers/purge/handler.rs — added output_format: OutputFormat to execute(), updated complete_workflow() to dispatch via Strategy Pattern
  • src/presentation/cli/dispatch/router.rsCommands::Purge arm reads context.output_format() and passes it to the controller
  • docs/user-guide/commands/purge.md — added JSON output section with examples
  • docs/issues/394-add-json-output-to-purge-command.md — marked all goals and checklist items as complete
  • project-words.txt — added checkmark to avoid cspell false positive

JSON Output Format

{
  "environment_name": "my-env",
  "purged": true
}

purged is always true on the success path — failures exit with a non-zero code and produce no JSON output.

Testing

  • All 2282 existing tests pass (cargo test --lib)
  • Unit tests added for PurgeDetailsData, JsonView, and TextView
  • Full linter suite passes (cargo run --bin linter all)
  • cargo machete — no unused dependencies

Notes for Manual Verification (Phase 5)

Before merging, a user with an existing environment can verify both outputs:

# Text (default)
cargo run -- purge <env> --force

# JSON
cargo run -- purge <env> --force --output-format json 2>/dev/null

Expected JSON:

{
  "environment_name": "<env>",
  "purged": true
}

@josecelano josecelano self-assigned this Feb 27, 2026
- Add PurgeDetailsData DTO with from_environment_name constructor
- Add JsonView and TextView for purge command (Strategy Pattern)
- Add output_format param to PurgeCommandController::execute()
- Dispatch to TextView or JsonView in complete_workflow()
- Update router to pass context.output_format() to purge controller
- Add unit tests for DTO, JsonView, and TextView
@josecelano josecelano force-pushed the 394-add-json-output-to-purge-command branch from a51eb53 to fa8c998 Compare February 27, 2026 08:31
@josecelano

Copy link
Copy Markdown
Member Author

ACK fa8c998

@josecelano josecelano merged commit 75dfe4d into main Feb 27, 2026
33 checks passed
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 purge command (12.12)

1 participant