Return structured JSON help from bare group commands when --json is active#304
Merged
Conversation
There was a problem hiding this comment.
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
--jsonis set. - Add unit tests covering JSON help output and ensuring bare-group text help remains unchanged without
--json. - Add an e2e test asserting
messages --jsonreturns 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--jsonis 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--agenthelp path inrootHelpFunc()to also trigger on--json, covering all bare group commands centrally--jsonflag only —--jq, config-drivenformat=json, and non-TTY piped output retain existing behaviorTest 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)bin/basecamp cards --jsonreturns JSON with"command":"cards","subcommands":[...]bin/basecamp cardsstill shows text help unchanged