Skip to content

chore: Improve --json support accross multiple commands#347

Open
blainekasten wants to merge 1 commit intonextfrom
blaine/dx-368-cleanup-json-output-implementation
Open

chore: Improve --json support accross multiple commands#347
blainekasten wants to merge 1 commit intonextfrom
blaine/dx-368-cleanup-json-output-implementation

Conversation

@blainekasten
Copy link
Copy Markdown
Contributor

Summary

Standardizes CLI JSON output on console.print_json(openapi_dumps(...).decode("utf-8")) so serialization matches the SDK (datetime, Pydantic, etc.) and stdout stays valid JSON for tooling like jq.

Changes

  • Consistency: Replaced ad hoc json.dumps, rich.print_json, and raw JSON strings with the shared openapi_dumps + console.print_json pattern across touched commands (files upload/check paths, fine-tuning list/cancel, endpoints & storage retrieve, evals retrieve JSON path, jig helpers).
  • Telemetry: telemetry status, enable, and disable accept the global --json flag and emit single JSON objects (telemetry status includes structured disabled/enabled + reason where relevant).
  • files retrieve-content: --json emits jq-friendly payloads: stdout-only (content or content_base64), output-only (id + path), or combined {content|content_base64, path} when both --stdout and --output are set so we never print two unrelated JSON documents on one invocation.
  • Jig: _print_cli_result and detach deploy summary use openapi_dumps; beta jig volumes describe prints human-readable fields without --json and full JSON with --json (replacing always-JSON behavior for the default path).
  • Tests: Relaxed retrieve-content stdout assertions for optional leading newline from the loading spinner; added test_telemetry_json_mode_pipes_to_jq.

Notes

  • openapi_dumps in _utils/_json.py remains the single JSON serializer for CLI output (no parallel “custom date” path).
  • Subprocess JSON/jq tests that hit a mock API base URL still require that environment in CI.

Closes DX-368 (or link the Linear issue).

@blainekasten blainekasten force-pushed the blaine/dx-368-cleanup-json-output-implementation branch 3 times, most recently from 5123ab7 to 5f5fcf3 Compare April 28, 2026 15:34
@blainekasten blainekasten force-pushed the blaine/dx-368-cleanup-json-output-implementation branch from 5f5fcf3 to 45fcff4 Compare April 28, 2026 17:15
@blainekasten blainekasten requested a review from zainhas April 28, 2026 17:22
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.

1 participant