Skip to content

Add --output=json support to ls command#270

Merged
AndreyVMarkelov merged 1 commit into
masterfrom
ls-json-output
Jun 22, 2026
Merged

Add --output=json support to ls command#270
AndreyVMarkelov merged 1 commit into
masterfrom
ls-json-output

Conversation

@AndreyVMarkelov

@AndreyVMarkelov AndreyVMarkelov commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactor ls to separate entry preparation from rendering, enabling both text and JSON output from the same data
  • JSON output emits {"input": {...}, "entries": [...]} with structured metadata per entry
  • Deleted entries use "deleted": true instead of <<...>> text decoration in JSON
  • Text output writes through cmd.OutOrStdout() instead of raw os.Stdout
  • Fix outputJSONRequested to use last-flag-wins semantics matching Cobra behavior

Test plan

  • go vet ./... clean
  • golangci-lint run ./... clean
  • All tests pass (go test ./... -count=1)
  • Manual: dbxcli ls --output=json / emits JSON entries array
  • Manual: dbxcli ls -l --output=json / includes input flags in JSON
  • Manual: dbxcli ls -d --output=json / shows deleted entries with deleted: true
  • Manual: dbxcli ls / text output unchanged

Refactor ls to separate entry preparation from rendering. JSON output
emits an entries array with structured metadata. Deleted entries use a
boolean field instead of <<>> text decoration. Also fix outputJSONRequested
to use last-flag-wins semantics matching Cobra behavior.
@AndreyVMarkelov AndreyVMarkelov merged commit fa8a556 into master Jun 22, 2026
7 checks passed
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