R/message_handler.R

Defines functions cut_item_to_print set_repo_scope show_message

#' @noRd
show_message <- function(host,
                         engine,
                         scope = NULL,
                         code = NULL,
                         information) {
  msg_graphql <- cli::col_yellow('GraphQl')
  msg_rest <- cli::col_green('REST')
  engine_msg <- if (engine == "graphql") {
    msg_graphql
  } else if (engine == "rest") {
    msg_rest
  } else if (engine == "both") {
    paste0(msg_rest, "&", msg_graphql)
  }
  information <- cli::col_br_blue(information)
  message <- if (is.null(scope)) {
    glue::glue("[Host:{host}][Engine:{engine_msg}] {information}...")
  } else {
    glue::glue("[Host:{host}][Engine:{engine_msg}][Scope:{scope}] {information}...")
  }
  cli::cli_alert(message)
}

set_repo_scope <- function(org, private) {
  paste0(org, ": ", length(private$orgs_repos[[org]]), " repos")
}

cut_item_to_print <- function(item_to_print) {
  if (length(item_to_print) < 10) {
    list_items <- paste0(item_to_print, collapse = ", ")
  } else {
    item_to_print_cut <- item_to_print[1:10]
    list_items <- paste0(item_to_print_cut, collapse = ", ") %>%
      paste0("... and ", length(item_to_print) - 10, " more")
  }
  return(list_items)
}

Try the GitStats package in your browser

Any scripts or data that you put into this service are public.

GitStats documentation built on June 8, 2025, 12:29 p.m.