Add --output flag with JSON structured output infrastructure#263
Merged
Conversation
Replace the boolean --json flag with a string --output flag (text, json). Commands opt in to JSON support via an annotation; unsupported commands return a clear error. Add jsonMetadata struct for file/folder metadata serialization decoupled from SDK types.
6 tasks
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.
Summary
--jsonflag with a global--outputstring flag (text,json) on the root commandenableStructuredOutput(cmd)to support--output=json; unannotated commands return a clearstructured output is not supported for this command yeterrorjsonMetadatastruct for serializing file/folder/deleted metadata to JSON, decoupled from SDK typesPersistentPreRunE(before auth) across root, login, logout, and team commandsTest plan
go vet ./...cleangolangci-lint run ./...cleango test ./... -count=1)dbxcli ls --output=jsonreturns unsupported error (no command opted in yet)dbxcli ls --output=yamlreturns invalid format error