Skip to content

feat: add global --json flag and deprecate per-command --format json#204

Merged
pchuri merged 2 commits into
mainfrom
feat/global-json-output
Jun 20, 2026
Merged

feat: add global --json flag and deprecate per-command --format json#204
pchuri merged 2 commits into
mainfrom
feat/global-json-output

Conversation

@pchuri

@pchuri pchuri commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

--format json was only supported on a subset of commands, and there was no consistent way to get machine-readable output for piping to tools like jq. This adds a global --json flag as the canonical mechanism and deprecates the per-command --format json (still honored, warns on stderr).

What changed

  • New global --json flag — works uniformly across all read/query commands.
  • Gap commands gain JSON output: search, spaces, find previously had no JSON option at all.
  • Existing --format json commands migrated to a shared lib/output helper: info, children, versions, comments, attachments, property-list/get/set. The deprecated --format json still works and prints a one-time deprecation warning to stderr.
  • Fail loud, not silent: passing --json to a command that doesn't support it (e.g. create, read) now errors with a clear message + exit 1, instead of silently emitting human-readable output.
  • Bug fix: comments no longer prints No comments found. to stdout in JSON mode — it now emits a valid empty JSON object, keeping stdout parseable.

Human-readable messages and warnings go to stderr, so stdout always stays valid JSON for jq.

Scope

This covers all read/query commands (the piping-to-jq use case from #203). Adding --json output to mutation commands (create returning id/url, etc.) is deferred to a follow-up; for now they fail loud on --json.

Testing

  • npm test — 741 passing (new tests/json-output.test.js covers --json, the --format json deprecation warning, clean empty output, and the fail-loud path).
  • npm run lint — clean.

Refs #203

pchuri added 2 commits June 20, 2026 21:28
Introduce a global --json flag as the canonical way to request
machine-readable output, and deprecate the per-command --format json
(still honored, warns once on stderr).

- Add JSON output to search, spaces, and find (previously unavailable)
- Route existing --format json commands through a shared lib/output
  helper (info, children, versions, comments, attachments, property-*)
- Reject --json on commands that don't support it with a clear error
  instead of silently emitting human-readable output
- Fix comments emitting "No comments found." to stdout in JSON mode

Refs #203
… fix

Bumps transitive form-data to 4.0.6 (CRLF injection, GHSA-hmw2-7cc7-3qxx)
and markdown-it to 14.2.0 (quadratic-complexity DoS, GHSA-6v5v-wf23-fmfq).
Lockfile-only and non-breaking; clears the production npm audit enforced by
the CI security job.
@pchuri pchuri merged commit ee523ee into main Jun 20, 2026
6 checks passed
@pchuri pchuri deleted the feat/global-json-output branch June 20, 2026 13:21
github-actions Bot pushed a commit that referenced this pull request Jun 20, 2026
# [2.13.0](v2.12.0...v2.13.0) (2026-06-20)

### Features

* add global --json flag and deprecate per-command --format json ([#204](#204)) ([ee523ee](ee523ee)), closes [#203](#203)
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.13.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant