Top level flag to specify directory to operate in
Describe the feature or problem you’d like to solve
For example your org has N number of projects you have cloned locally where N may be more then 100. To list all PRs on all projects you need to repeatedly access each project and run gh pr list for N times.
Unwanted scenario:
cd <project>
gh pr list
cd ..
# Repeat N times
Proposed solution
It would be nice to have such key in to level flags such --dir, --repo or --project-path to have such operation possible:
for proj in $(ls); do gh --project-path=$rpoj pr list; done
or to have kind of .ghrc where someone could list all current projects (configuration file in YAML, JSON, or INI format )
It would be helpful for DevOps teams they usually have to deal with all projects at the same time.
Thanks for writing in!
We already support the --repo flag:
gh pr list --repo cli/cli
However, that flag requires you to know the owner/repo pair for a GitHub repo.
If you're operating on local directories exclusively (and don't know exactly which GitHub repos their remotes map to), maybe a flag like git's -C would be useful? https://github.com/cli/cli/issues/1931
gh -C path/to/project pr list
@mislav #1913 git-like -C flag looks exactly what I would like to have, thanks 👍
It also mentioned -R flag which I could not find in my current gh version
gh --version
gh version 1.0.0 (2020-09-16)
https://github.com/cli/cli/releases/tag/v1.0.0
UP
-R flag is not in top level
simple hack to list all PRs on all repos cloned locally, assuming that all of them belong to one <org>
ls | xargs -I{} bash -c 'echo ____________ {}; gh pr list -R <org>/{}' >> ../gh-pr-list
@mislav May I ask if there's any update? Or is this something already on the roadmap? Thank you!
@ryenus No update; nothing on the roadmap.
This option would be really useful.
I see git and the other GitHub CLI hub both support this flag --git-dir=<path> which is very useful when your current working directory isn't within the repository you want to run actions on.
Looking at how this is done in Git, it's actually quite straightforward, each -C is treated as like a cd option to change the current working directory (CWD). It would be nice if someone familiar with go can help move this forward.
Maybe add the help wanted label? @mislav or anyone from the team? Just for the status quo.
Currently must work around this with cd or pushd, not hopeful for any movement after 2 years.
Agreed; this can be taken up by the community since we failed to do so ourselves.
Tip for implementers: this can probably be done using Cobra global flags and PreRun hooks.