You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh cs commands accept a -r flag to filter to a specific repo #6548
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
Do you/the team have any recommendations to handling that? I think it would be:
Only have --repo for cs cp (which makes it slightly different from all the other commands)
Repurpose -r for cs cp and break anything currently using -r
Could switch --recursive to -R instead to keep the short flag
Could go with option 1 for now and mark -r as deprecated for some time?
Start migrating codespaces commands to -R instead of -r to avoid the collision, mark existing -r as deprecated
Option 1 is basically long term pain to avoid short term hassle - option 2 is the opposite.
My inclination is option 2, but would love feedback for how to reduce pain from breakage and generally how the CLI prefers to handle that type of change.
Option 3 is a good opportunity to align the codespaces commands with other commands on using -R and avoids breaking changes and special casing entirely. Leaving the -r options to be deprecated would impact the create, delete, and list.
Most of the other commands seem to use a shared option:
-R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO format
Another option would be to use -R for consistency with the rest of the CLI and support -r as a deprecated backwards-compatible option for e.g. cs create which already has -r as a synonym for --repo.
All of the gh cs commands use -r instead of -R, but I agree that this is somewhat confusing. Switching to -R and supporting -r for backwards compatibility sounds like a good idea to me!
Actually I really like that suggestion @rneatherway - the discrepancy of -r/-R in the codespaces command set had bugged me for a while, but I hand't considered just getting two birds with one stone here 😄 I updated the list of options above with that.
Activity
jungaretti commentedon Nov 1, 2022
This makes sense to me!
mislav commentedon Nov 7, 2022
We (the CLI core team) have discussed this and the proposal looks good!
Note that one codespace command
cs cpalready has an unrelated-rflag.cmbrose commentedon Nov 7, 2022
Thanks for catching that in
cs cp@mislav!Do you/the team have any recommendations to handling that? I think it would be:
--repoforcs cp(which makes it slightly different from all the other commands)-rforcs cpand break anything currently using-r--recursiveto-Rinstead to keep the short flag-ras deprecated for some time?-Rinstead of-rto avoid the collision, mark existing-ras deprecatedOption 1 is basically long term pain to avoid short term hassle - option 2 is the opposite.My inclination is option 2, but would love feedback for how to reduce pain from breakage and generally how the CLI prefers to handle that type of change.
Option 3 is a good opportunity to align the codespaces commands with other commands on using
-Rand avoids breaking changes and special casing entirely. Leaving the-roptions to be deprecated would impact thecreate,delete, andlist.rneatherway commentedon Dec 12, 2022
Drive-by comment, please feel free to ignore.
Most of the other commands seem to use a shared option:
Another option would be to use
-Rfor consistency with the rest of the CLI and support-ras a deprecated backwards-compatible option for e.g.cs createwhich already has-ras a synonym for--repo.jungaretti commentedon Dec 12, 2022
All of the
gh cscommands use-rinstead of-R, but I agree that this is somewhat confusing. Switching to-Rand supporting-rfor backwards compatibility sounds like a good idea to me!cmbrose commentedon Dec 12, 2022
Actually I really like that suggestion @rneatherway - the discrepancy of
-r/-Rin the codespaces command set had bugged me for a while, but I hand't considered just getting two birds with one stone here 😄 I updated the list of options above with that.