Skip to content

Add --json output to read commands#77

Open
akshithg wants to merge 1 commit into
mainfrom
add-json-output
Open

Add --json output to read commands#77
akshithg wants to merge 1 commit into
mainfrom
add-json-output

Conversation

@akshithg

Copy link
Copy Markdown
Member

Adds a --json flag to the read/query commands so agents and scripts can consume untruncated, structured output instead of the formatted tables. Default table rendering is unchanged.

Commands

  • list --json — droplets (id, name, status, ip, tailscale_ip, region, size, cost_monthly, in_ssh_config, ssh_hostname, tags), hibernated, total_monthly_cost
  • info --json — the list fields plus created_at, vcpus, memory_mb, disk_gb, transfer_tb, image, features, full networks (incl. IPv6)
  • list-ssh-keys --json — username and ssh_keys (name/id/fingerprint)
  • version --json — version string

Notes

  • Shared emit_json() and field-extraction builders are centralized; build_droplet_detail reuses build_droplet_record rather than duplicating extraction.
  • Missing values are emitted as null, not placeholder strings.
  • JSON mode suppresses decorative status lines.
  • Follow-up planned: --json + non-interactive --yes for the mutating commands.

Tests

New tests/test_list.py and tests/test_json_output.py cover the builders and all four commands. Full suite: 291 passed; coverage 30.61%. (The 12 test_rename.py failures are pre-existing on main, unrelated to this change.)

🤖 Generated with Claude Code

Add a --json flag to the read/query commands (list, info, list-ssh-keys,
version) so agents and scripts can consume untruncated, structured output
instead of the formatted tables. The default table rendering is unchanged.

Shared serialization (emit_json) and field extraction are centralized:
build_droplet_detail reuses build_droplet_record for the info command, and
the same helper is used across commands rather than duplicated.

Missing values are emitted as null rather than placeholder strings so
consumers can branch on them. JSON mode suppresses decorative status lines.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@akshithg akshithg requested a review from ret2libc as a code owner June 26, 2026 00:10
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