Skip to content

Add JSON help output - #237

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
abhinavgautam01:feature/help-json-114
Jun 21, 2026
Merged

andrew merged 1 commit into
git-pkgs:mainfrom
abhinavgautam01:feature/help-json-114

Conversation

@abhinavgautam01

Copy link
Copy Markdown
Contributor

Summary

Adds structured command discovery via git pkgs help --format json, as a prerequisite for the MCP server work in #114.

Ref #114

Changes

  • Add a custom Cobra help command with --format text|json
  • Preserve existing text help behavior
  • Serialize command metadata as JSON:
    • command name/path/usage
    • short and long descriptions
    • aliases
    • runnable status
    • local, persistent and inherited flags
    • nested subcommands
  • Include discovered plugin commands in the JSON command tree
  • Document the new structured help output in the README
  • Add tests for root JSON help, command-specific JSON help, unsupported formats and plugin discovery

Testing

  • go test ./cmd -run HelpJSON
  • go run . help where --format json
  • go run . help list
  • go test ./...
  • go tool golangci-lint run ./...
  • git diff --check
  • go build ./...

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a custom help command implementation to support structured command discovery via git pkgs help --format json, enabling downstream tooling (e.g., MCP server work in #114) to introspect the full command tree without scraping text help.

Changes:

  • Adds a Cobra help override that supports --format text|json and emits a JSON command/flag tree.
  • Ensures plugin commands discovered on PATH are included in the JSON output.
  • Documents the feature in README.md and adds focused tests for JSON help behavior (root, specific command, invalid format, plugins).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
README.md Documents the new structured JSON help output usage.
cmd/root.go Registers the new JSON-capable help command on the root command.
cmd/help.go Implements the custom help command and JSON serialization of commands/flags.
cmd/help_test.go Adds tests validating JSON help output and plugin discovery inclusion.

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

Comment thread cmd/help.go Resolved
@abhinavgautam01
abhinavgautam01 force-pushed the feature/help-json-114 branch from c537599 to 0d0faf9 Compare June 19, 2026 10:28
@andrew
andrew merged commit 693e53e into git-pkgs:main Jun 21, 2026
4 checks passed
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.

3 participants