Skip to content

Expose 'googlesheets4_quiet' in the function API, or advertise it better #326

@MichaelChirico

Description

@MichaelChirico

I was trying to figure out how to quiet the sheets output messages:

✔ Reading from ${BOOK_TITLE}.

✔ Range ''${SHEET_TITLE}''.

Naturally, I checked ?read_sheet to figure this out, expecting a quiet= option.

I found none, and might have concluded it's not possible to do so, but I doggedly chased down the source code, clicking through 3 definitions before finding it's possible:

msg <- glue(
"
Reading from {.s_sheet {x$name}}<<sheet_msg>><<range_msg>>.",
.open = "<<",
.close = ">>"
)
gs4_bullets(c(v = msg))

googlesheets4/R/utils-ui.R

Lines 131 to 140 in 55cd9fd

gs4_bullets <- function(text, .envir = parent.frame()) {
quiet <- gs4_quiet() %|% is_testing()
if (quiet) {
return(invisible())
}
cli::cli_div(theme = gs4_theme())
# TODO: fix this: when I switched from cli::cli_bullets() to
# cli::cli_inform(), my custom bullet styling was lost (suppressing colour)
cli::cli_bullets(text, .envir = .envir)
}

gs4_quiet <- function() {
getOption("googlesheets4_quiet", default = NA)
}

It would be nice to have this directly as an option; otherwise, one of the @examples could set this option to demonstrate it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions