diff --git a/R/consent.R b/R/consent.R index dc23d26..70cc08a 100644 --- a/R/consent.R +++ b/R/consent.R @@ -24,6 +24,13 @@ #' @return `TRUE` if consent is given, otherwise an error is raised. #' #' @export +#' @examples +#' \dontrun{ +#' +#' # to provide consent and prevent other functions from interrupting to get the consent +#' rje_consent(provided = TRUE) +#' } +#' rje_consent <- function(provided = FALSE) { # Check if consent is already given via environment variable diff --git a/R/java_manage.R b/R/java_manage.R index f556576..394b695 100644 --- a/R/java_manage.R +++ b/R/java_manage.R @@ -1,17 +1,28 @@ -#' List the contents of the Java cache +#' List the contents of the Java versions installed or cached #' -#' @param type The type of cache to list: "distrib", "installed", or "project". -#' @param output The format of the output: "data.frame" or "vector". Defaults to "data.frame". +#' @description +#' This function lists one of the following: +#' +#' * `project` - list the contents of the Java symlinked/copied in the current project or directory specified by `target_dir` +#' +#' * `distrib` - list the contents of the downloaded Java distributions cache in default location or specified by `target_dir` +#' +#' * `installed` - list the contents of the Java installations cache (unpacked distributions) in default location or specified by `target_dir` +#' +#' @param type The type of cache to list: "distrib", "installed", or "project". Defaults to "project". +#' @param output The format of the output: `data.frame`` or `vector``. Defaults to `data.frame`. #' @inheritParams global_quiet_param #' @param target_dir The cache directory to list. Defaults to the user-specific data directory for "distrib" and "installed", and the current working directory for "project". -#' @return A data frame or character vector with the contents of the specified cache directory. +#' @return A `dataframe` or `character` `vector` with the contents of the specified cache or project directory. #' @export #' #' @examples +#' \dontrun{ #' java_list("project") #' java_list("installed") #' java_list("distrib") -#' +#'} +#' java_list <- function( type = c("project", "installed", "distrib"), output = c("data.frame", "vector"), @@ -24,7 +35,7 @@ java_list <- function( if (type == "project") { target_dir <- getwd() } else { - target_dir <- tools::R_user_dir("rJavaEnv", which = "cache") + target_dir <- getOption("rJavaEnv.cache_path") } } @@ -49,9 +60,11 @@ java_list <- function( #' @export #' #' @examples +#' \dontrun{ #' java_clear("project") #' java_clear("installed") #' java_clear("distrib") +#' } #' java_clear <- function( type = c("project", "installed", "distrib"), diff --git a/R/java_manage_distrib_cache.R b/R/java_manage_distrib_cache.R index 87042e1..a4137ba 100644 --- a/R/java_manage_distrib_cache.R +++ b/R/java_manage_distrib_cache.R @@ -6,11 +6,7 @@ #' @inheritParams global_quiet_param #' @return A character vector with the contents of the cache directory. #' -#' @examples -#' \dontrun{ -#' java_list_distrib_cache() -#' } -#' +#' @keywords internal java_list_distrib_cache <- function( cache_path = getOption("rJavaEnv.cache_path"), output = c("data.frame", "vector"), @@ -21,7 +17,7 @@ java_list_distrib_cache <- function( cache_path <- file.path(cache_path, "distrib") if (!dir.exists(cache_path)) { - cli::cli_alert_danger("Path does not exist") + cli::cli_alert_danger("No Java distributions have been downloaded.") return(character(0)) } if (!quiet) cli::cli_inform("Contents of the Java distributions cache folder:") @@ -48,17 +44,7 @@ java_list_distrib_cache <- function( #' @inheritParams java_download #' @return A message indicating whether the cache was cleared or not. #' -#' @examples -#' \dontrun{ -#' # delete all cached distributions -#' # if you leave `cache_path` empty, the function -#' # will clear in the package cache in your default user space cache -#' java_clear_distrib_cache( -#' cache_path = tempdir(), -#' check = FALSE, -#' delete_all = TRUE -#' ) -#' } +#' @keywords internal java_clear_distrib_cache <- function( cache_path = getOption("rJavaEnv.cache_path"), check = TRUE, diff --git a/R/java_manage_installed_cache.R b/R/java_manage_installed_cache.R index 086b536..9adab10 100644 --- a/R/java_manage_installed_cache.R +++ b/R/java_manage_installed_cache.R @@ -4,12 +4,7 @@ #' @param cache_path The cache directory to list. Defaults to the user-specific data directory. Not recommended to change. #' @inheritParams global_quiet_param #' @return A data frame or character vector with the contents of the cache directory. -#' -#' @examples -#' \dontrun{ -#' java_list_installed_cache() -#' } -#' +#' @keywords internal java_list_installed_cache <- function( output = c("data.frame", "vector"), quiet = TRUE, @@ -19,7 +14,7 @@ java_list_installed_cache <- function( installed_cache_path <- file.path(cache_path, "installed") if (!dir.exists(installed_cache_path)) { - cli::cli_alert_danger("Path does not exist") + cli::cli_alert_danger("No Java distributions have been installed yet.") return(character(0)) } @@ -59,10 +54,7 @@ java_list_installed_cache <- function( #' @param delete_all Whether to delete all installations without prompting. Defaults to FALSE. #' @return A message indicating whether the cache was cleared or not. #' -#' @examples -#' \dontrun{ -#' java_clear_installed_cache() -#' } +#' @keywords internal java_clear_installed_cache <- function( check = TRUE, delete_all = FALSE, diff --git a/R/java_manage_project.R b/R/java_manage_project.R index b3e0d42..906b625 100644 --- a/R/java_manage_project.R +++ b/R/java_manage_project.R @@ -4,7 +4,7 @@ #' @param output The format of the output: "data.frame" or "vector". Defaults to "data.frame". #' @inheritParams global_quiet_param #' @return A data frame or character vector with the symlinked Java versions in the project directory. -#' +#' @keywords internal java_list_in_project <- function( project_path = NULL, output = c("data.frame", "vector"), @@ -61,11 +61,8 @@ java_list_in_project <- function( #' @param check Whether to list the symlinked Java versions before clearing them. Defaults to TRUE. #' @param delete_all Whether to delete all symlinks without prompting. Defaults to FALSE. #' @return A message indicating whether the symlinks were cleared or not. -#' -#' @examples -#' \dontrun{ -#' java_clear_in_project() -#' } +#' +#' @keywords internal java_clear_in_project <- function( project_path = NULL, check = TRUE, diff --git a/man/java_clear.Rd b/man/java_clear.Rd index bbb1b4b..8fcc60a 100644 --- a/man/java_clear.Rd +++ b/man/java_clear.Rd @@ -27,8 +27,10 @@ A message indicating whether the cache was cleared or not. Wrapper function to clear the Java symlinked in the current project, installed, or distributions caches. } \examples{ +\dontrun{ java_clear("project") java_clear("installed") java_clear("distrib") +} } diff --git a/man/java_clear_distrib_cache.Rd b/man/java_clear_distrib_cache.Rd index 208972a..0a5ffc8 100644 --- a/man/java_clear_distrib_cache.Rd +++ b/man/java_clear_distrib_cache.Rd @@ -23,15 +23,4 @@ A message indicating whether the cache was cleared or not. \description{ Clear the Java distributions cache folder } -\examples{ -\dontrun{ -# delete all cached distributions -# if you leave `cache_path` empty, the function -# will clear in the package cache in your default user space cache -java_clear_distrib_cache( - cache_path = tempdir(), - check = FALSE, - delete_all = TRUE -) -} -} +\keyword{internal} diff --git a/man/java_clear_in_project.Rd b/man/java_clear_in_project.Rd index 7e569b7..467be59 100644 --- a/man/java_clear_in_project.Rd +++ b/man/java_clear_in_project.Rd @@ -19,8 +19,4 @@ A message indicating whether the symlinks were cleared or not. \description{ Clear the Java versions symlinked in the current project } -\examples{ -\dontrun{ -java_clear_in_project() -} -} +\keyword{internal} diff --git a/man/java_clear_installed_cache.Rd b/man/java_clear_installed_cache.Rd index d422940..635ae22 100644 --- a/man/java_clear_installed_cache.Rd +++ b/man/java_clear_installed_cache.Rd @@ -23,8 +23,4 @@ A message indicating whether the cache was cleared or not. \description{ Clear the Java installations cache folder } -\examples{ -\dontrun{ -java_clear_installed_cache() -} -} +\keyword{internal} diff --git a/man/java_list.Rd b/man/java_list.Rd index 9c6fcfe..8570969 100644 --- a/man/java_list.Rd +++ b/man/java_list.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/java_manage.R \name{java_list} \alias{java_list} -\title{List the contents of the Java cache} +\title{List the contents of the Java versions installed or cached} \usage{ java_list( type = c("project", "installed", "distrib"), @@ -12,23 +12,30 @@ java_list( ) } \arguments{ -\item{type}{The type of cache to list: "distrib", "installed", or "project".} +\item{type}{The type of cache to list: "distrib", "installed", or "project". Defaults to "project".} -\item{output}{The format of the output: "data.frame" or "vector". Defaults to "data.frame".} +\item{output}{The format of the output: \verb{data.frame`` or }vector``. Defaults to \code{data.frame}.} \item{quiet}{A \code{logical} value indicating whether to suppress messages. Can be \code{TRUE} or \code{FALSE}.} \item{target_dir}{The cache directory to list. Defaults to the user-specific data directory for "distrib" and "installed", and the current working directory for "project".} } \value{ -A data frame or character vector with the contents of the specified cache directory. +A \code{dataframe} or \code{character} \code{vector} with the contents of the specified cache or project directory. } \description{ -List the contents of the Java cache +This function lists one of the following: +\itemize{ +\item \code{project} - list the contents of the Java symlinked/copied in the current project or directory specified by \code{target_dir} +\item \code{distrib} - list the contents of the downloaded Java distributions cache in default location or specified by \code{target_dir} +\item \code{installed} - list the contents of the Java installations cache (unpacked distributions) in default location or specified by \code{target_dir} +} } \examples{ +\dontrun{ java_list("project") java_list("installed") java_list("distrib") +} } diff --git a/man/java_list_distrib_cache.Rd b/man/java_list_distrib_cache.Rd index ac7b321..54f26a9 100644 --- a/man/java_list_distrib_cache.Rd +++ b/man/java_list_distrib_cache.Rd @@ -23,9 +23,4 @@ A character vector with the contents of the cache directory. \description{ List the contents of the Java distributions cache folder } -\examples{ -\dontrun{ -java_list_distrib_cache() -} - -} +\keyword{internal} diff --git a/man/java_list_in_project.Rd b/man/java_list_in_project.Rd index 0d277ce..6f97d2f 100644 --- a/man/java_list_in_project.Rd +++ b/man/java_list_in_project.Rd @@ -23,3 +23,4 @@ A data frame or character vector with the symlinked Java versions in the project \description{ List the Java versions symlinked in the current project } +\keyword{internal} diff --git a/man/java_list_installed_cache.Rd b/man/java_list_installed_cache.Rd index 29e4db3..73a39ec 100644 --- a/man/java_list_installed_cache.Rd +++ b/man/java_list_installed_cache.Rd @@ -23,9 +23,4 @@ A data frame or character vector with the contents of the cache directory. \description{ List the contents of the Java installations cache folder } -\examples{ -\dontrun{ -java_list_installed_cache() -} - -} +\keyword{internal} diff --git a/man/rje_consent.Rd b/man/rje_consent.Rd index ae0710f..1a50d15 100644 --- a/man/rje_consent.Rd +++ b/man/rje_consent.Rd @@ -33,3 +33,11 @@ The function is based on the code of the \code{renv} package. Copyright 2023 Posit Software, PBC License: https://github.com/rstudio/renv/blob/main/LICENSE } +\examples{ +\dontrun{ + +# to provide consent and prevent other functions from interrupting to get the consent +rje_consent(provided = TRUE) +} + +}