Skip to content

gh cs commands accept a -r flag to filter to a specific repo #6548

@cmbrose

Description

@cmbrose

For gh cs commands which show a codespace selection prompt (code, ssh, ports, etc), we can accept an optional -r parameter to specify a repo. This parameter can be used to pre-filter the list of codespaces and in the case that only a single codespace matches, auto-select it.

In terms of implementation, most/all of these commands go through getOrChooseCodespace, so adding the parameter there should allow all of these commands to get the same functionality at once.

For example:

Without -r

$ gh cs code
? Choose codespace:  [Use arrows to move, type to filter]
> cli/cli (trunk): didactic parakeet
  cli/cli (trunk): fictional fiesta
  devcontainer/features (main): humble train

Multiple matches with -r

$ gh cs code -r cli/cli
? Choose codespace:  [Use arrows to move, type to filter]
> cli/cli (trunk): didactic parakeet
  cli/cli (trunk): fictional fiesta

Multiple matches with -r

$ gh cs code -r devcontainer/features
(vscode immediately opens "humble train")

No matches with -r

$ gh cs code -r foo/bar
Error: no codespaces exist for the specified repository

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions