Visitar URL original
Feature request: allow selecting fields for human-readable list output · Issue #14413 · cli/cli · GitHub
Skip to content

Feature request: allow selecting fields for human-readable list output #14413

Agent suggestions

Public preview

Description

@ItsSidhartha

What would you like to be added?

Add a --fields option to list commands such as gh pr list to allow users to select which fields are displayed in the human-readable table.

For example:

gh pr list --fields number,title,author,state

could produce:

NUMBER  TITLE                    AUTHOR   STATE
123     Fix authentication      alice    OPEN
124     Update dependencies     bob      MERGED
125     Improve documentation   carol    OPEN

The order of the fields would determine the order of the columns.

Motivation

Today, gh pr list provides a predefined human-readable table, while --json provides field selection for structured output.

If a user wants a slightly different human-readable table, they currently need to move to --json and then use --jq or --template to construct the output.

For example, selecting a few fields is straightforward:

gh pr list --json number,title,author,state

but turning those fields back into a table requires additional formatting:

gh pr list \
  --json number,title,author,state \
  --template '{{range .}}{{tablerow .number .title .author.login .state}}{{end}}'

There seems to be a useful middle ground between the fixed default table and fully programmable output:

gh pr list --fields number,title,author,state

The intention is to make common table customization simple without introducing another query or formatting language.

Proposed behavior

--fields would select fields that have a defined, human-readable representation suitable for a single table cell.

Scalar fields would be supported directly, for example:

number
title
state
isDraft
createdAt
updatedAt
closedAt
mergedAt
additions
deletions
changedFiles

Some non-scalar fields also have an obvious single-value representation and could potentially be supported. For example:

author           → author.login
mergedBy         → mergedBy.login
milestone        → milestone.title
headRepository   → headRepository.nameWithOwner
mergeCommit      → mergeCommit.oid

The exact set of supported fields and their representations would be part of the design.

Fields representing collections such as labels, assignees, comments, commits, files, reviews, etc. could initially be excluded rather than introducing arbitrary serialization rules.

For structured or custom transformations, users would continue to use --json, --jq, or --template.

Why not make this a general JSON/field-path selector?

The goal would intentionally be to keep --fields simple.

For example, this proposal is not intended to introduce expressions such as:

gh pr list --fields 'labels[].name'

or arbitrary JSON traversal/transformation.

That functionality is already better served by --json together with --jq or --template.

Instead, --fields would expose a curated set of fields that gh knows how to render naturally in a table.

Open questions

I'd be interested in maintainer/community feedback on:

  1. Is there a specific reason this functionality does not currently exist?
  2. Is --fields a suitable name, or would another name be preferable?
  3. Should the option be limited to scalar fields?
  4. Which non-scalar fields have sufficiently obvious representations to include?
  5. Should fields such as author, milestone, and headRepository have predefined representations as proposed above?
  6. Should collection fields such as labels and assignees be excluded, or should they have a simple representation such as comma-separated values?
  7. Should this functionality be available consistently across other list commands (gh issue list, gh run list, etc.), or should it initially be specific to gh pr list?
  8. Should the set of --fields values exactly match the fields available to --json, or should the two have separate field sets?
  9. Is there an existing internal abstraction for field selection/rendering that this could build on?

Alternatives

The existing --json, --jq, and --template options can accomplish this today, so this proposal is primarily about making the common case more discoverable and concise.

The proposed feature would not replace those options; it would provide a simpler interface for selecting predefined human-readable fields.

Example

Instead of:

gh pr list \
  --json number,title,author,state \
  --template '{{range .}}{{tablerow .number .title .author.login .state}}{{end}}'

allow:

gh pr list --fields number,title,author,state

while retaining the existing structured-output options for users who need more control.

Activity

  1. cli-triage commented on Sep 10, 2026

    @cli-triage

    This looks like a clear, well-scoped feature request rather than a bug: today's human-readable table columns for commands like gh pr list are indeed hardcoded (e.g. number/title/branch/state are added via fixed table.AddField calls in pkg/cmd/pr/list/list.go lines 245-252), with no way to customize which fields appear without falling back to --json/--template. I found no existing open or closed issue proposing this --fields-style option, so it doesn't appear to be a duplicate. I'm suggesting the enhancement label along with gh-pr since the example centers on gh pr list, though the author notes this could extend to other list commands.

    Generated by Issue Triage (skills-driven) for #14413 · copilot · auto · 47.4 AIC · ⌖ 2.12 AIC · ⊞ 10K · ◷

  2. williammartin commented on Sep 10, 2026

    @williammartin
    Member

    Hey thanks for raising this, @ItsSidhartha. Some quick thoughts:

    Is there a specific reason this functionality does not currently exist?

    No, in fact I think I explored something 2 years ago very similar to this through the lens of accessibility, allowing screenreader users to reorder information in the easiest to consume manner: 327cb83

    I'll try and update the branch today and and maybe we can start playing around with it and seeing how different UX feels because while all your other questions are great for design discussion, I'm just not sure I can answer them off hand. Probably requires some focused design work (though we are pretty hammered with work right now).

    Was there some work that you were doing where you found this would be really useful? Just looking for motivation for prioritising this feature with a jillion other things.

  3. github-actions commented on Sep 10, 2026

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.

    Unless you see the help wanted Contributions welcome label, we are not currently looking for external contributions for this feature.

    If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.

  4. ItsSidhartha commented on Sep 10, 2026

    @ItsSidhartha
    Author

    Thanks @williammartin, for the consideration,

    Was there some work that you were doing where you found this would be really useful? Just looking for motivation for prioritising this feature with a jillion other things.

    Actually No, I was just playing around with the tool, and I tried to see the all the PR with author, then I felt it would be nice and helpfull if I can customise the fields I want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementa request to improve CLI

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions