fix(cli): add deleted_at field to project delete JSON/YAML output #6639

Merged
HAL9000 merged 1 commits from fix/issue-6314-project-delete-output into master 2026-04-10 19:45:43 +00:00
3 changed files with 36 additions and 1 deletions
+5
View File
@@ -196,6 +196,11 @@ Feature: Project CLI command functions coverage
When I invoke project-delete for "local/del-json" with yes format "json"
Then the project cmd output should contain "deleted"
Scenario: delete command JSON includes deletion timestamp
Given a project "local/del-json-ts" is created in the commands DB
When I invoke project-delete for "local/del-json-ts" with yes format "json"
Then the project cmd JSON data should include deleted_at
Scenario: delete nonexistent project fails
When I invoke project-delete for "local/nope" with yes
Then the project cmd should fail
@@ -12,6 +12,7 @@ database, then restored after every step that needs them.
from __future__ import annotations
import json
from io import StringIO
from typing import Any
@@ -675,3 +676,22 @@ def step_cmd_fail(context: Any) -> None:
assert context._cmd_failed, (
f"Expected command to fail but it succeeded. Output:\n{context._cmd_output}"
)
@then("the project cmd JSON data should include deleted_at")
def step_cmd_json_has_deleted_at(context: Any) -> None:
output = context._cmd_output.strip()
try:
envelope = json.loads(output)
except json.JSONDecodeError as exc:
raise AssertionError(
f"Command output is not valid JSON:\n{context._cmd_output}"
) from exc
data = envelope.get("data")
assert isinstance(data, dict), (
f"Expected envelope data to be a dict, got {type(data).__name__}: {data}"
)
assert "deleted_at" in data, (
f"Expected 'deleted_at' in command JSON data, got keys {list(data.keys())}"
)
+11 -1
View File
@@ -19,6 +19,7 @@ Based on ADR-009 (CLI Framework) and implementation_plan.md task B0.cli.projects
from __future__ import annotations
import re
from datetime import UTC, datetime
from pathlib import Path
from typing import Annotated, Any
@@ -977,4 +978,13 @@ def delete(
if output_format.lower() == OutputFormat.RICH:
console.print(f"[green]✓[/green] Project '{name}' deleted.")
else:
console.print(format_output({"deleted": name, "success": True}, output_format))
console.print(
format_output(
{
"deleted": name,
"success": True,
"deleted_at": datetime.now(tz=UTC),
},
output_format,
)
)