Skip to content

Make tab completion available for more flags like labels and projects #11406

Open

Description

@kilasuit

Describe the bug

Using the gh cli using PowerShell, I expect that I should be able to tab complete all manner of things, that include labels projects and more

This is not the case today, so so it seems without wrapping the gh cli in other tooling and pulling together a local cache that updates as part of any call to the GitHub apis

Affected version

2.76.0

Steps to reproduce the behavior

This was an actual command that I ran & wanted to tab complete the labels in use in the repo vs then manually going to the repo and updating the labels.

gh issue create -t "Update the Working Group definitions markdown and pull in membership from a json file" `
--body 'the working group definitions should be in a json file so that we can query them and they should be able to be emeded in the markdown file' `
-R PowerShell/PowerShell `
--assignee kilasuit

Expected vs actual behavior

Ability to tab complete the labels that are in use for that repo as well as all projects that I have access to (personal or organisational)

Logs

No logs from this action

Activity

  1. added
    bug
    on Jul 29, 2025
  2. added
    needs-triage
    on Jul 29, 2025
  3. self-assigned this
    on Jul 31, 2025
  4. babakks commented on Jul 31, 2025

    @babakks
    Member

    Hi, @kilasuit! And thanks for your suggestion! 🙏

    As you said, not all command options support auto-completion, and it's because due to the remarkable number of such options we have to choose wisely and prioritise those that actually bring value to the table. So, I wouldn't label this issue as bug Something isn't working , and would rather stamp an enhancement a request to improve CLI on it.

    Regarding labels, projects, etc, I think as a starter labels make more sense. It seems like a simple addition and also the data is easily available through a single (paginated) API request (See below for details). It will also enhance the UX for the following commands:

    • pr create/edit/list
    • issue create/edit/list

    As of projects, they can be a bit tricky, especially regarding the sunsetting of ProjectsV1 and the multiple API requests needed to fetch all projects that a user has access to (i.e. projects available for a repo, projects owned by the user, etc). I'm not saying auto-completion for projects should be skipped, but it definitely requires a separate issue and needs more time for investigation.

    Since this is an enhancement request, what I'm going to do is to keep this issue open for further internal discussion and will update you here.

    Retrieving labels

    The API simply provides the labels via this GraphQL query, and we already have it implemented in the codebase:

    query {
      repository(owner: "cli", name: "cli") {
        labels(first: 100) {
          nodes {
            name
          }
        }
      }
    }

    cli/api/queries_repo.go

    Lines 1287 to 1300 in a2e23a2

    // RepoLabels fetches all the labels in a repository
    func RepoLabels(client *Client, repo ghrepo.Interface) ([]RepoLabel, error) {
    type responseData struct {
    Repository struct {
    Labels struct {
    Nodes []RepoLabel
    PageInfo struct {
    HasNextPage bool
    EndCursor string
    }
    } `graphql:"labels(first: 100, orderBy: {field: NAME, direction: ASC}, after: $endCursor)"`
    } `graphql:"repository(owner: $owner, name: $name)"`
    }

    And as an example of how to override the auto-completion behaviour this is a good one where the information about the base repo is needed to perform the API request:

    _ = cmd.RegisterFlagCompletionFunc("reviewer", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
    results, err := requestableReviewersForCompletion(opts)
    if err != nil {
    return nil, cobra.ShellCompDirectiveError
    }
    return results, cobra.ShellCompDirectiveNoFileComp
    })

  5. added
    enhancement
    gh-pr
    gh-issue
    and removed
    bug
    on Jul 31, 2025
  6. github-actions commented on Jul 31, 2025

    @github-actions
    Contributor

    Thank you for your issue! We have categorized it as a feature 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.

  7. changed the title [-]Tab completion seems not to be feature complete[/-] [+]Make tab completion available for more flags like labels and projects[/+] on Aug 12, 2025
  8. added
    core
    and removed
    needs-triage
    on Dec 8, 2025
  9. babakks commented on Dec 10, 2025

    @babakks
    Member

    @BagToad and I looked into this and decided it's more complicated than what meets the eye, hence we marked it as core This issue is not accepting PRs from outside contributors . It's mostly due to the need to resolve the base repo before the actual invocation of the command.

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

    coreenhancementgh-issuegh-pr

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions