As an operator, developer, or CI automation user, I want consistent machine‑readable JSON output for all photoprism show … CLI commands so I can script checks, integrate with tooling, and validate configurations without parsing human‑formatted tables.
Implemented Changes
- JSON format support across all “show” commands
- Flag:
--json, -j (part of shared report.CliFlags).
- Renderer: pkg/txt/report supports Format(JSON) and renders tables as JSON.
- JSON shape and keys
- Single-table commands (file-formats, thumb-sizes, video-sizes, sources, search-filters) return a top-level array of row objects.
- Keys derive from column names using snake_case (spaces/dashes → “_”, lowercase, punctuation removed).
- Multi-section and special cases:
- show config → { "sections": [{ "title", "items": [ {...} ] }, ...] } (unchanged).
- show config-options → top-level array (flattened across sections).
- show config-yaml → top-level array (flattened across sections).
- show metadata → { "items": [ {...} ], "docs": [ {...} ] } (docs omitted when --short).
- All values are strings (parity with CSV/TSV for stable tooling).
- Flag conflict validation
- Exactly one of
--json | --md | --csv | --tsv; conflicts return cli.Exit with code 2.
- Markdown output preserved for docs
- show config-options --md and show config-yaml --md render section headings + tables for docs ingestion.
- Help text and descriptions
- report.CliFlags usage strings clarified (“print machine‑readable …”).
- Command descriptions for show config-options and show config-yaml note that text/Markdown is sectioned while JSON/CSV/TSV are flat lists.
- Plus/Pro builds
- Commands that use
report.CliFlags inherit --json automatically; config-options/config-yaml JSON is flat there as well.
Note: JSON output for the photoprism show config-options and photoprism show config-yaml commands is a flat, top-level array, unlike the standard and Markdown-formatted outputs.
How To Use
- Examples
photoprism show sources --json | jq '.[0]'
photoprism show thumb-sizes --json | jq '.[0] | {name, width, height}'
photoprism show file-formats --json | jq 'map({format, type, extensions}) | .[0]'
photoprism show config --json | jq '.sections[0].items[0]' # still sectioned
photoprism show config-options --json | jq '.[0]' # now flat array
photoprism show config-yaml --json | jq '.[0]' # now flat array
photoprism show metadata --json | jq '{items: (.items|length), docs: (.docs//[])|length}'
photoprism show metadata --json --short | jq 'keys' # docs omitted
- Flag conflict check
photoprism show sources --json --csv; echo $? # expect exit code 2
Manual Test Checklist
- Single-table commands emit a JSON array of objects
- Keys are snake_case, values are strings; sample keys match column intent (source, priority, description, …).
- Multi-section and special cases
- show config → sections[].title present; sections[].items is an array of objects.
- show config-options → top-level array (no sections).
- show config-yaml → top-level array (no sections).
- show metadata → items present; docs present unless --short is set.
- Markdown for docs remains sectioned
- photoprism show config-options --md includes “### Authentication” and a valid Markdown table.
- photoprism show config-yaml --md includes per-section headings and tables.
- CSV/TSV behave unchanged (single table, delimited).
- Plus/Pro (if available locally) accept --json and produce valid JSON; config-options/config-yaml are flat arrays there, too.
Acceptance Criteria
Notes
- Code: pkg/txt/report/* (JSON renderer, key canonicalization); internal/commands/show_*.go (CliFormatStrict; JSON assembly where needed).
- CLI help updated to clarify sectioned text/Markdown vs flat machine formats.
- Docs/specs updated (as of 2025-09-21) to reflect JSON shapes and Markdown docs integration.
As an operator, developer, or CI automation user, I want consistent machine‑readable JSON output for all
photoprism show …CLI commands so I can script checks, integrate with tooling, and validate configurations without parsing human‑formatted tables.Implemented Changes
--json,-j(part of shared report.CliFlags).--json|--md|--csv|--tsv; conflicts returncli.Exitwith code 2.report.CliFlagsinherit --json automatically; config-options/config-yaml JSON is flat there as well.Note: JSON output for the
photoprism show config-optionsandphotoprism show config-yamlcommands is a flat, top-level array, unlike the standard and Markdown-formatted outputs.How To Use
photoprism show sources --json | jq '.[0]'photoprism show thumb-sizes --json | jq '.[0] | {name, width, height}'photoprism show file-formats --json | jq 'map({format, type, extensions}) | .[0]'photoprism show config --json | jq '.sections[0].items[0]'# still sectionedphotoprism show config-options --json | jq '.[0]'# now flat arrayphotoprism show config-yaml --json | jq '.[0]'# now flat arrayphotoprism show metadata --json | jq '{items: (.items|length), docs: (.docs//[])|length}'photoprism show metadata --json --short | jq 'keys'# docs omittedphotoprism show sources --json --csv; echo $?# expect exit code 2Manual Test Checklist
Acceptance Criteria
Notes