Skip to content

feat(cli): add global --json flag for machine-readable output#40

Merged
christso merged 1 commit into
mainfrom
feat/json-output
Feb 1, 2026
Merged

feat(cli): add global --json flag for machine-readable output#40
christso merged 1 commit into
mainfrom
feat/json-output

Conversation

@christso
Copy link
Copy Markdown
Contributor

@christso christso commented Feb 1, 2026

Summary

  • Add a global --json flag that outputs a consistent JSON envelope { success, command, data?, error? } to stdout for all CLI commands
  • Parse and strip --json from process.argv before cmd-ts processes args, so it works in any position
  • Human-readable output remains identical when --json is not passed
  • Error cases with --json output structured JSON error with process.exit(1)

Test plan

  • E2e tests verify every command outputs valid parseable JSON with correct envelope fields
  • E2e tests verify error cases return { success: false, error: "..." } with exit code 1
  • E2e tests verify --json works in different positions (before/between subcommands)
  • E2e tests verify human output is unchanged without --json
  • All 290 tests pass, typecheck clean, build succeeds

Closes #3

🤖 Generated with Claude Code

Add a --json flag that can be placed anywhere in the command args.
When set, all commands output a consistent JSON envelope to stdout
with { success, command, data?, error? } structure. Human-readable
output remains unchanged when --json is not used.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying allagents with  Cloudflare Pages  Cloudflare Pages

Latest commit: 864067f
Status:🚫  Build failed.

View logs

@christso christso merged commit 7ccf843 into main Feb 1, 2026
1 check failed
@christso christso deleted the feat/json-output branch February 1, 2026 01:35
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