cli / cli/cli

Add --json-default (or bare --json) to mirror default table columns in list commands

Open
#13,765 1 comment 0 reactions 0 assignees View on GitHub
enhancement gh-issue gh-pr gh-run stale
Dominant language
Go
Stars
46.3k
Forks
9k
Avg merge
2d 9h
Merged PRs (30d)
89

Description

### Describe the feature or problem you'd like to solve

`gh issue list` (and `gh pr list`, `gh run list`, etc.) print a nice default table: number, title, labels, state, updated-at. But the moment you want JSON — the 90% case for scripting — `--json` requires you to enumerate every field:

```
$ gh issue list --repo cli/cli --json
Specify one or more comma-separated fields for `--json`:
assignees author blockedBy blocking body closed closedAt ...
```

That's ~25 fields to pick from every time. Every script or agent ends up hardcoding something like `--json number,title,state,labels,updatedAt` — which is fragile (typos), verbose, and inconsistent across scripts.

### Proposed solution

Add a **`--json-default`** shortcut (or accept `--json` with no argument, or `--json=default`) that emits the same columns the default table shows:

```
$ gh issue list --repo cli/cli --json-default
[{"number": 13764, "title": "...", "state": "OPEN", "labels": [...], "updatedAt": "..."}]
```

Value:
- Matches the mental model of "give me the table, but as JSON."
- Stable for scripts that don't care about specific fields, just want to iterate over the list they'd otherwise see on-screen.
- Discoverable — `--help` can document the default set per command.

Alternative shape: `--json` without arguments prints the default columns instead of erroring (arguably a small backwards-compat break, but the current error path is a UX cliff).

### Additional context

Distinct from #10385 (which is scoped to `gh search prs` implying `--json` when `--jq` is used). This is about the *default column set* being reachable in JSON mode across all `... list` commands.

Related: #8890 (hyperlinks/headers in `gh pr list`), #9152 (piped-output edge cases).

Not asking for auto-detection or magic — just a named shortcut for the columns the tool already knows are the sensible defaults.

Contributor guide

Open the contributing guide

Research direction

Start by comparing the existing --json behavior across gh issue list, gh pr list, and gh run list, including their default table columns and help text. Trace how list commands validate JSON fields, then determine how the proposed named shortcut should work consistently across commands. Done means the default table fields can be requested as JSON and are covered by command-level tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.