mirror of
https://github.com/gopasspw/gopass.git
synced 2026-05-30 11:18:48 +02:00
dc14463c35
Addresses I-3 from the code quality audit: add JSON output to the four
commands most useful for scripting and integration.
Changes:
- internal/audit/report.go: add json struct tags to Finding,
SecretReport and Report so marshaling produces a stable schema.
Findings/Template/Duration fields that are internal or format-specific
are tagged json:"-".
- internal/audit/output.go: add RenderJSON(io.Writer) that encodes a
lightweight {duration, secrets} payload with indented JSON and add
encoding/json import.
- internal/action/audit.go: wire 'json' as a valid --format value,
routing to saveReport(…, RenderJSON, …, "json").
- internal/action/commands.go: update --format usage string to include
'json'; add --json / -j bool flag to list, find, and recipients.
- internal/action/list.go: when --json is set, call listJSON() which
reuses the existing tree.Root.List / ListFolders path and writes a
JSON array to stdout. Add jsonWrite() helper shared across the
package. Direct-hit (exact-match) path also respects --json.
- internal/action/find.go: check --json before the single-match and
non-terminal branches so scripting callers (non-TTY or explicit
'find') get a JSON array; no-match still returns a non-zero exit.
- internal/action/recipients.go: when --json is set, call
Store.RecipientsTree with pretty=false, take the flat List() and
write a JSON array; skip the human-readable hint in JSON mode.
- internal/action/{list,find,recipients,audit}_test.go: new sub-tests
that call each JSON path, unmarshal the output and assert structure.