Skip to content

Commit 5f03762

Browse files
committed
Add gh function to query rate limits
1 parent 1429655 commit 5f03762

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: nflversedata
22
Title: nflverse data storage functions
3-
Version: 0.0.13
3+
Version: 0.0.14
44
Authors@R:c(
55
person("Tan", "Ho", , "tan@tanho.ca", role = c("aut", "cre"),
66
comment = c(ORCID = "0000-0001-8388-5155")),

R/gh_cli.R

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,26 @@ gh_cli_release_assets <- function(tag, ..., repo = "nflverse/nflverse-data"){
113113
ret
114114
}
115115

116+
#' @export
117+
gh_cli_rate_limits <- function(verbose = TRUE){
118+
# Make sure the gh cli is available
119+
gh_cli_available()
120+
121+
# create command for the shell
122+
cli_command <- "gh api rate_limit"
123+
124+
cli_output <- .invoke_cli_command(cli_command = cli_command)
125+
126+
all_rates <- .cli_parse_json(cli_output = cli_output)
127+
rate <- all_rates$rate
128+
129+
rate$reset_parsed <- format(as.POSIXct(rate$reset, origin = "1970-01-01", tz = "UTC"), usetz = TRUE)
130+
131+
if (isTRUE(verbose)) cli::cli_ul(paste0(names(rate), " : ", rate))
132+
133+
invisible(all_rates)
134+
}
135+
116136
#' @export
117137
.invoke_cli_command <- function(cli_command){
118138
# This command will error regularly on R error and also errors on warnings

0 commit comments

Comments
 (0)