Originally created by: fu351
No doberman subcommand has machine-readable output today (verified: no --json/--format flag exists anywhere in src/doberman/cli/) — with two exceptions already tracked separately: [#178] (doberman scan --json), [#179] (doberman doctor --json), and [#180] (doberman log --jsonl). doberman policy-history (policy_history(), src/doberman/cli/main.py:885, backed by read_policy_changes() in src/doberman/policy/drift.py:566) is the one remaining table-only command most likely to get piped into other tooling. Add a --json flag that dumps the same redacted rows read_policy_changes() returns as a single JSON array. The default human-readable output must be byte-for-byte unchanged.
Note: this issue originally also covered doberman log. That's now redundant with [#180], which adds a --jsonl flag to log — scoped here to policy-history only so the two issues don't duplicate work.
One small, mechanical change: add a Typer --json flag, branch to json.dumps([...]) instead of the existing typer.echo table loop.
src/doberman/cli/main.py — policy_history() (line 885); already imports json at module scope for other uses.src/doberman/policy/drift.py — read_policy_changes() (line 566), the redacted dict shape policy_history() renders.doberman policy-history --json prints a valid JSON array of the same redacted rows the human view shows.--json) output is unchanged.--json output either (same redaction as the human view).ruff check . && ruff format --check . and lint-imports passpytest passesdoberman policy-history --json | python -m json.tool
doberman log's JSON support is [#180]'s scope (JSON Lines, not a JSON array) — do not duplicate it here.--json to any other command in this issue.read_policy_changes()'s return shape.New here? Start with CONTRIBUTING.md. Issues are labelled level-1 (docs only) through level-10 (new subsystem) — pick one at your level and climb. Comment to claim an issue before starting.
Ticket changed by: fu351