Add --json output to read commands#77
Open
akshithg wants to merge 1 commit into
Open
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
--jsonflag 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_costinfo --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 stringNotes
emit_json()and field-extraction builders are centralized;build_droplet_detailreusesbuild_droplet_recordrather than duplicating extraction.null, not placeholder strings.--json+ non-interactive--yesfor the mutating commands.Tests
New
tests/test_list.pyandtests/test_json_output.pycover the builders and all four commands. Full suite: 291 passed; coverage 30.61%. (The 12test_rename.pyfailures are pre-existing onmain, unrelated to this change.)🤖 Generated with Claude Code