Skip to content

fix: json flag issue interactive mode - #86

Merged
felipefreitag merged 8 commits into
resend:mainfrom
Shubham-Rasal:fix-json-flag-issue-interactive-mode
Mar 17, 2026
Merged

fix: json flag issue interactive mode#86
felipefreitag merged 8 commits into
resend:mainfrom
Shubham-Rasal:fix-json-flag-issue-interactive-mode

Conversation

@Shubham-Rasal

@Shubham-Rasal Shubham-Rasal commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #74


Summary by cubic

Treats the --json flag as non-interactive across the CLI to suppress prompts and require explicit flags, even in TTY sessions. Extends this to all remaining commands and shared prompts, with tests ensuring consistent, pipeable JSON output. Fixes #74.

  • Bug Fixes

    • Guard all interactive branches with !globalOpts.json (replace bare isInteractive()).
    • login/remove/switch: with --json, require explicit flags (e.g., --key, --name); skip profile selection and plain-text confirmations.
    • send/broadcasts/templates/webhooks/contacts/api-keys: with --json, require non-interactive flags; exit with missing_* codes; suppress prompts (e.g., contact first/last name); in send, do not fetch domains.
  • Tests

    • Added TTY-mode tests for login, remove, switch, api-keys, broadcasts, contacts (create/add-segment/update-topics), templates, webhooks, and shared prompts verifying no prompts and correct errors in --json; ensure domains list is not fetched in send.
    • Added templates create coverage (success, missing_name/body, auth_error, create_error) and moved command parent cleanup to afterEach to prevent state leaks.

Written for commit e90e733. Summary will update on new commits.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 6 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Shubham-Rasal and others added 2 commits March 14, 2026 11:47
Extends the globalOpts.json guard to all remaining bare isInteractive()
calls so that --json output is always pipeable to jq without prompts
interrupting. Adds tests verifying --json suppresses prompts even when
isTTY is true, and fixes pre-existing lint formatting in login/send tests.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 20 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="tests/commands/contacts/add-segment.test.ts">

<violation number="1" location="tests/commands/contacts/add-segment.test.ts:171">
P2: The new test mutates the shared addContactSegmentCommand instance by attaching it to a parent Command, but the cleanup is only at the end of the happy path. If the test fails before the reset, the singleton keeps its parent and can leak state into later tests. Move the reset into a finally/afterEach cleanup to make it failure-safe.</violation>
</file>

<file name="tests/commands/broadcasts/create.test.ts">

<violation number="1" location="tests/commands/broadcasts/create.test.ts:403">
P2: The new test mutates the shared `createBroadcastCommand` singleton by adding it as a subcommand, but only resets `parent` on the happy path. If the test throws before cleanup, the shared command stays attached and can pollute later tests that reuse it. Consider moving the reset into `afterEach` or a `try/finally` so it always runs.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread tests/commands/contacts/add-segment.test.ts Outdated
Comment thread tests/commands/broadcasts/create.test.ts
@felipefreitag felipefreitag changed the title Fix json flag issue interactive mode fix: json flag issue interactive mode Mar 17, 2026
felipefreitag and others added 3 commits March 17, 2026 11:43
The shared command singleton's parent was only reset at the end of the
test body, leaking state if the test threw before cleanup. Move the
reset into afterEach via a commandRef variable so it always runs.

@felipefreitag felipefreitag left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation looks good, but it should cover the whole surface of the CLI

@felipefreitag
felipefreitag merged commit 81a2be8 into resend:main Mar 17, 2026
8 checks passed
@Shubham-Rasal

Copy link
Copy Markdown
Contributor Author

Thanks for the feedback. Will keep it in mind for next time!

The implementation looks good, but it should cover the whole surface of the CLI

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.

Remove interactive mode when using --json to improve jq support

2 participants