Describe the feature or problem you’d like to solve
I manage quite a few GitHub orgs and periodically need to do one-off data collection about those orgs, the repos they contain, and the teams within them. Often times, the easiest solution to these sorts of one-off data collection problems is to squish gh and jq together in an unholy bash oneliner. However, actually running through the queries I want, across thousands of repositories, both takes a while to run and churns through API rate limit tokens.
My solution to this is a wrapper that caches all responses from gh locally, refreshing the cache contents if they contain a rate limit response or if I force it to.
Recently, I noticed that the gh api subcommand accepts a --cache option flag. This piqued my interest. "Maybe I can toss this one-off wrapper and just use the built-in cache", says I to myself. Unfortunately, I can't find any documentation that explains precisely what this control does or what valid configuration values are. From digging through the code, it appears that this value is parsed by time.ParseDuration, which hints at the valid configuration values, and then sets a header that appears to be passed without other handling to http.Client. Go is not my forte, so it's likely I'm missing something, but I can't figure out from an hour or so diving through the code, what in fact this caching feature does or how it works.
Proposed solution
As a first step, documenting how the feature works would be wonderful. If it does everything I need, then cool, end of discussion. :) If it doesn't, then I'll know where to start discussing adding new capabilities (specifically: the ability to force a cache update is critical.)
Describe the feature or problem you’d like to solve
I manage quite a few GitHub orgs and periodically need to do one-off data collection about those orgs, the repos they contain, and the teams within them. Often times, the easiest solution to these sorts of one-off data collection problems is to squish
ghandjqtogether in an unholy bash oneliner. However, actually running through the queries I want, across thousands of repositories, both takes a while to run and churns through API rate limit tokens.My solution to this is a wrapper that caches all responses from
ghlocally, refreshing the cache contents if they contain a rate limit response or if I force it to.Recently, I noticed that the
gh apisubcommand accepts a--cacheoption flag. This piqued my interest. "Maybe I can toss this one-off wrapper and just use the built-in cache", says I to myself. Unfortunately, I can't find any documentation that explains precisely what this control does or what valid configuration values are. From digging through the code, it appears that this value is parsed bytime.ParseDuration, which hints at the valid configuration values, and then sets a header that appears to be passed without other handling tohttp.Client. Go is not my forte, so it's likely I'm missing something, but I can't figure out from an hour or so diving through the code, what in fact this caching feature does or how it works.Proposed solution
As a first step, documenting how the feature works would be wonderful. If it does everything I need, then cool, end of discussion. :) If it doesn't, then I'll know where to start discussing adding new capabilities (specifically: the ability to force a cache update is critical.)