Skip to content

Return structured JSON help from bare group commands when --json is active#304

Merged
jeremy merged 1 commit into
mainfrom
bc-9679133061
Mar 15, 2026
Merged

Return structured JSON help from bare group commands when --json is active#304
jeremy merged 1 commit into
mainfrom
bc-9679133061

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 15, 2026

Summary

  • When --json is passed to a bare group command (basecamp cards --json, basecamp messages --json, etc.), the help function now emits structured JSON instead of plain text that breaks JSON parsers
  • Extends the existing --agent help path in rootHelpFunc() to also trigger on --json, covering all bare group commands centrally
  • Scoped to the explicit --json flag only — --jq, config-driven format=json, and non-TTY piped output retain existing behavior

Test plan

  • go test ./internal/cli/... — 3 new unit tests (TestJSONHelpProducesStructuredJSON, TestBareGroupJSONHelpProducesJSON, TestBareGroupTextHelpUnchanged)
  • make test-e2e — 1 new e2e test (messages --json shows structured JSON help)
  • bin/ci — full CI suite passes (linter skipped locally due to parallel worktree contention; unit + e2e + vet all green)
  • Manual: bin/basecamp cards --json returns JSON with "command":"cards","subcommands":[...]
  • Manual: bin/basecamp cards still shows text help unchanged

@jeremy jeremy requested a review from a team as a code owner March 15, 2026 21:26
Copilot AI review requested due to automatic review settings March 15, 2026 21:26
@github-actions github-actions Bot added tests Tests (unit and e2e) enhancement New feature or request labels Mar 15, 2026
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 3 files

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CLI help rendering so that when --json is explicitly provided and help is shown (notably for bare group commands like basecamp messages --json), the help output is emitted as structured JSON rather than human-formatted text that can break JSON consumers.

Changes:

  • Extend the existing structured “agent help” JSON path to also trigger when --json is set.
  • Add unit tests covering JSON help output and ensuring bare-group text help remains unchanged without --json.
  • Add an e2e test asserting messages --json returns structured JSON help.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
internal/cli/help.go Routes help rendering to structured JSON when --json is set (in addition to --agent).
internal/cli/help_test.go Adds unit tests validating structured JSON help and unchanged text help behavior.
e2e/errors.bats Adds an e2e assertion that messages --json outputs structured JSON help.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jeremy jeremy merged commit e22e19f into main Mar 15, 2026
30 checks passed
@jeremy jeremy deleted the bc-9679133061 branch March 15, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants