Repository navigation
gh cs commands accept a -r flag to filter to a specific repo #6548
Description
Activity
This makes sense to me!
- addedenhancementa request to improve CLIa request to improve CLIand removedneeds-triageneeds to be reviewedneeds to be reviewed
on 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.Thanks for catching that in
cs cp@mislav!Do you/the team have any recommendations to handling that? I think it would be:
- Only have
--repoforcs cp(which makes it slightly different from all the other commands) - Repurpose
-rforcs cpand break anything currently using-r- Could switch
--recursiveto-Rinstead to keep the short flag - Could go with option 1 for now and mark
-ras deprecated for some time?
- Could switch
- Start migrating codespaces commands to
-Rinstead of-rto avoid the collision, mark existing-ras 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
-Rand avoids breaking changes and special casing entirely. Leaving the-roptions to be deprecated would impact thecreate,delete, andlist.- Only have
Drive-by comment, please feel free to ignore.
Most of the other commands seem to use a shared option:
-R, --repo [HOST/]OWNER/REPO Select another repository using the [HOST/]OWNER/REPO formatAnother 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.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!Reacted by Robin NeatherwayActually 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.Reacted by Robin Neatherway
For
gh cscommands which show a codespace selection prompt (code,ssh,ports, etc), we can accept an optional-rparameter 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
-rMultiple matches with
-rMultiple 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