Skip to content

Add --json output to scope list#106

Merged
ewega merged 3 commits intomainfrom
copilot/add-json-output-to-list-commands
Mar 4, 2026
Merged

Add --json output to scope list#106
ewega merged 3 commits intomainfrom
copilot/add-json-output-to-list-commands

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 4, 2026

  • Audit existing JSON output in connection list and project list (both already implemented)
  • Add scopeListItem struct and --json output path to configure_scope_list.go
  • Add TestScopeListItem_JSONFields and TestRunScopeList_JSONRequiresFlags tests to json_output_test.go
  • go build ./... and go test ./... pass
  • Code review: no comments
  • CodeQL: no alerts
  • README.md: add configure scope list and configure project list rows to --json commands table
  • docs/configure-scope.md: add --json flag note, requirement, and JSON output example to scope list section
Original prompt

This section details on the original issue you should resolve

<issue_title>Add --json output to connection list, scope list, and project list</issue_title>
<issue_description>## Problem

Only status honors the global --json flag. The list commands (connection list, scope list, project list) output formatted tables to stderr but have no structured output mode.

The plumbing already exists:

  • outputJSON bool in root.go:12
  • printJSON() helper in helpers.go:65-73

These just need to be wired into the three list commands.

Scope of Changes

configure_connection_list.go

When outputJSON is true, collect connections into a []statusConnection (or similar struct) and call printJSON() instead of writing the formatted table.

configure_scope_list.go

When outputJSON is true, output scope entries as JSON array.

configure_project_list.go

When outputJSON is true, output project entries as JSON array.

Acceptance Criteria

  • gh devlake configure connection list --json outputs valid JSON to stdout
  • gh devlake configure scope list --plugin github --connection-id 1 --json outputs valid JSON to stdout
  • gh devlake configure project list --json outputs valid JSON to stdout
  • Without --json, all three commands still output human-readable tables (no behavior change)
  • go build ./... and go test ./... pass</issue_description>

<agent_instructions>The plumbing exists: outputJSON bool in root.go:12, printJSON() helper in helpers.go:65-73. Wire these into the three list commands. When outputJSON is true, collect the data into a slice/struct and call printJSON() instead of writing formatted tables. For connection list, reuse the connection structs from internal/devlake/types.go. For scope list and project list, use the existing response types. Don't change behavior when --json is not set. Build with go build ./... and test with go test ./....</agent_instructions>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copilot AI changed the title [WIP] Add --json output to connection, scope, and project lists Add --json output to scope list Mar 4, 2026
Copilot finished work on behalf of ewega March 4, 2026 12:05
@ewega ewega marked this pull request as ready for review March 4, 2026 12:10
Copilot AI review requested due to automatic review settings March 4, 2026 12:10
Copy link
Copy Markdown
Contributor

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

Adds structured --json output support to gh devlake configure scope list, bringing it in line with other list commands (connection list, project list) and ensuring the command can produce machine-readable output without interactive prompts.

Changes:

  • Added a JSON output path to scope list, including a scopeListItem representation and quiet discovery when outputJSON is enabled.
  • Enforced --plugin and --connection-id as required inputs in JSON mode to avoid interactive prompts.
  • Added unit tests covering JSON field names/omitempty behavior and the JSON-mode flag requirement error.

Reviewed changes

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

File Description
cmd/configure_scope_list.go Implements --json output for scope listing, including non-interactive guardrails and quiet discovery.
cmd/json_output_test.go Adds tests for scopeListItem JSON shape and JSON-mode required-flag behavior.

@ewega
Copy link
Copy Markdown
Contributor

ewega commented Mar 4, 2026

@copilot Two documentation updates needed:

  1. README.md — Add configure scope list to the "Commands that support --json" table (around line 255). Add a row showing the command and its JSON shape [{id, name, fullName}].

  2. docs/configure-scope.md — In the scope list section, add a note that --json (global flag) is supported and requires --plugin + --connection-id. Add a JSON output example showing the shape.

…d configure-scope.md

Co-authored-by: ewega <26189114+ewega@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 4, 2026

@copilot Two documentation updates needed:

  1. README.md — Add configure scope list to the "Commands that support --json" table (around line 255). Add a row showing the command and its JSON ...

Done in df51c3a:

  • README.md: added rows for configure scope list ([{id, name, fullName}]) and configure project list ([{name, description, blueprintId}]) to the --json commands table.
  • docs/configure-scope.md: added a --json note to the scope list Flags section explaining that flags are required in JSON mode, plus a JSON output example in the Examples block.

Copilot finished work on behalf of ewega March 4, 2026 12:41
@ewega ewega merged commit 2d249a2 into main Mar 4, 2026
7 checks passed
@ewega ewega deleted the copilot/add-json-output-to-list-commands branch March 4, 2026 13:42
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.

Add --json output to connection list, scope list, and project list

3 participants