|
1 | 1 | check_extension_approval <- function(no_prompt = FALSE, what = "Something", see_more_at = NULL) { |
2 | | - if (!no_prompt) { |
3 | | - if (!rlang::is_interactive()) { |
4 | | - cli::cli_abort(c( |
5 | | - "{ what } requires explicit approval.", |
6 | | - ">" = "Set {.arg no_prompt = TRUE} if you agree.", |
7 | | - if (!is.null(see_more_at)) { |
8 | | - c(i = "See more at {.url {see_more_at}}") |
9 | | - } |
10 | | - )) |
11 | | - } else { |
12 | | - cli::cli_inform(c( |
13 | | - "{what} may execute code when documents are rendered. ", |
14 | | - "*" = "If you do not trust the author(s) of this {what}, we recommend that you do not install or use this {what}." |
15 | | - )) |
16 | | - prompt_value <- tolower(readline(sprintf("Do you trust the authors of this %s (Y/n)? ", what))) |
17 | | - if (!prompt_value %in% "y") { |
18 | | - cli::cli_inform("{what} not installed.") |
19 | | - return(invisible(FALSE)) |
| 2 | + if (no_prompt) return(TRUE) |
| 3 | + |
| 4 | + if (!rlang::is_interactive()) { |
| 5 | + cli::cli_abort(c( |
| 6 | + "{ what } requires explicit approval.", |
| 7 | + ">" = "Set {.arg no_prompt = TRUE} if you agree.", |
| 8 | + if (!is.null(see_more_at)) { |
| 9 | + c(i = "See more at {.url {see_more_at}}") |
20 | 10 | } |
| 11 | + )) |
| 12 | + } else { |
| 13 | + cli::cli_inform(c( |
| 14 | + "{what} may execute code when documents are rendered. ", |
| 15 | + "*" = "If you do not trust the author(s) of this {what}, we recommend that you do not install or use this {what}." |
| 16 | + )) |
| 17 | + prompt_value <- tolower(readline(sprintf("Do you trust the authors of this %s (Y/n)? ", what))) |
| 18 | + if (!prompt_value %in% "y") { |
| 19 | + cli::cli_inform("{what} not installed.") |
| 20 | + return(invisible(FALSE)) |
21 | 21 | } |
22 | 22 | } |
23 | 23 | } |
0 commit comments