Skip to content

feat: add --json output to mutation commands#205

Merged
pchuri merged 2 commits into
mainfrom
feat/json-mutations
Jun 21, 2026
Merged

feat: add --json output to mutation commands#205
pchuri merged 2 commits into
mainfrom
feat/json-mutations

Conversation

@pchuri

@pchuri pchuri commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #204. Extends the global --json flag to all write/mutation commands, completing --json coverage "across all commands" as requested in #203. Their results (new page id/url, deletion confirmations, purge counts) are now machine-readable for scripting and jq.

PAGE_ID=$(confluence create "Notes" ENG --content "hi" --json | jq -r '.id')
confluence delete "$PAGE_ID" --yes --json | jq '.deleted'

What changed

  • --json added to: create, create-child, update, move, delete, copy-tree, comment, comment-delete, property-delete, attachment-upload, attachment-delete, version-delete, versions-purge.
  • All 13 command names registered in the JSON_COMMANDS allowlist so the --json preAction guard (added in feat: add global --json flag and deprecate per-command --format json #204) permits them.
  • Destructive commands require --yes in --json mode — they refuse with a clear error instead of trying to prompt interactively (which would block a pipe and pollute stdout).
  • Progress / confirmation chatter is suppressed in --json mode (e.g. copy-tree's progress lines, versions-purge's per-version output), so stdout stays a single valid JSON document.
  • Mutations key off the global --json only (via wantsJson()), never the per-command --format flag — on create/update/comment that --format is the input content format and is left untouched.

Notes

  • edit is read-only (fetches content for editing), export/convert/init are local/file commands — these remain outside --json scope and reject it with the standard error.
  • No dependency changes.

Testing

  • npm test — 744 passing (new tests cover a non-destructive mutation, a destructive --yes success, and the destructive guard).
  • npm run lint — clean.

Closes #203

pchuri added 2 commits June 20, 2026 22:42
Extend the global --json flag to all write commands so their results
(new page id/url, deletion confirmations, purge counts) are machine-readable
for scripting and jq, completing --json coverage across the CLI.

- create / create-child / update / move / delete / copy-tree
- comment / comment-delete / property-delete
- attachment-upload / attachment-delete / version-delete / versions-purge
- destructive commands require --yes in --json mode (no interactive prompt)
- progress and confirmation chatter is suppressed so stdout stays valid JSON

Closes #203
…ped output

process.exit() can terminate before a piped stdout write flushes, truncating the JSON failure payload from `copy-tree --json --fail-on-error`. Set process.exitCode and return so the event loop drains stdout first.
@pchuri pchuri merged commit bccdbd3 into main Jun 21, 2026
6 checks passed
@pchuri pchuri deleted the feat/json-mutations branch June 21, 2026 07:11
github-actions Bot pushed a commit that referenced this pull request Jun 21, 2026
# [2.14.0](v2.13.0...v2.14.0) (2026-06-21)

### Features

* add --json output to mutation commands ([#205](#205)) ([bccdbd3](bccdbd3)), closes [#203](#203)
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.14.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.

[FEATURE] Support --format json across all commands

1 participant