% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/config.R
\name{config}
\alias{config}
\title{Configuration}
\usage{
config
}
\value{
list of functions that returns config values
}
\description{
\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#experimental}{\figure{lifecycle-experimental.svg}{options: alt='[Experimental]'}}}{\strong{[Experimental]}}
Internal configuration helpers used to retrieve package configuration
values from options or environment variables.

Configuration is resolved in the following order:
\enumerate{
\item \code{getOption("redcapsync.config.option.name")}
\item \code{Sys.getenv("REDCAPSYNC_CONFIG_OPTION_NAME")} # skipped for functions
\item Default if unable to find and validate from above.
}
}
\details{
The config function is operational but only some methods presently
affect internal code. Most users will not ever need to modify default config.
This is included to improve future versions of the package.
\itemize{
\item Working configs: \code{allow.test.names}, \code{cache.dir}, \code{keyring},
\code{keyring.service}, \code{openxlsx.header.style}, \code{openxlsx.body.style}.
\item Partial coverage: \code{offline}.
\item Placeholder: \code{verbose}, \code{show.api.messages}
}
\subsection{allow.test.names}{

Logical for \code{\link[=setup_project]{setup_project()}} allowing \code{project_name} starting with TEST_.
Default is \code{FALSE}. This is provided for developers and testing environments.

\if{html}{\out{<div class="sourceCode">}}\preformatted{# check current value package is using...
config$allow.test.names()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.allow.test.names") # get
options(redcapsync.config.allow.test.names = FALSE) # set

# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_ALLOW_TEST_NAMES")  # get
Sys.setenv(REDCAPSYNC_CONFIG_ALLOW_TEST_NAMES = FALSE) # or set in .Renviron
}\if{html}{\out{</div>}}
}

\subsection{show.api.messages}{

Logical for showing display API messages from REDCapR and redcapAPI.
Default is \code{FALSE}.

\if{html}{\out{<div class="sourceCode">}}\preformatted{# check current value package is using...
config$show.api.messages()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.show.api.messages") # get
options(redcapsync.config.show.api.messages = FALSE) # set

# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_SHOW_API_MESSAGES") # get
Sys.setenv(REDCAPSYNC_CONFIG_SHOW_API_MESSAGES = FALSE) # or set in .Renviron
}\if{html}{\out{</div>}}
}

\subsection{verbose}{

Logical for showing display API messages from REDCapR and redcapAPI.
Default is \code{FALSE}.

\if{html}{\out{<div class="sourceCode">}}\preformatted{# check current value package is using...
config$verbose()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.verbose") # get
options(redcapsync.config.verbose = FALSE) # set

# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_VERBOSE") # get
Sys.setenv(REDCAPSYNC_CONFIG_VERBOSE = FALSE) # or set in .Renviron
}\if{html}{\out{</div>}}
}

\subsection{offline}{

Logical for offline, which if TRUE will block any API calls.
Default is \code{FALSE}.

\if{html}{\out{<div class="sourceCode">}}\preformatted{# check current value package is using...
config$offline()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.offline") # get
options(redcapsync.config.offline = FALSE) # set

# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_OFFLINE") # get
Sys.setenv(REDCAPSYNC_CONFIG_OFFLINE = FALSE) # or set in .Renviron
}\if{html}{\out{</div>}}
}

\subsection{cache.dir}{

Character file path overriding the default cache directory. Default follow
system standards via rappdir, hoardr, or R_USER_CACHE_DIR

\if{html}{\out{<div class="sourceCode">}}\preformatted{# check current value package is using...
config$cache.dir()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.cache.dir") # get
options(redcapsync.config.cache.dir = "file/path/to/keep/cache") # set

# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_CACHE_DIR") # get
Sys.setenv(REDCAPSYNC_CONFIG_CACHE_DIR = "file/path/to/keep/cache") # set
}\if{html}{\out{</div>}}
}

\subsection{keyring}{

Character keyring name (parameter from \code{\link[keyring]{keyring}}
package). Default is NULL, which is at the system level. For locking use a
keyring like "REDCapSync"

\if{html}{\out{<div class="sourceCode">}}\preformatted{# check current value package is using...
config$keyring()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.keyring") # get
options(redcapsync.config.keyring = "REDCapSync") # set

# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_KEYRING") # get
Sys.setenv(REDCAPSYNC_CONFIG_KEYRING = "REDCapSync") # set in session
}\if{html}{\out{</div>}}
}

\subsection{keyring.service}{

Character keyring service name (parameter from \code{\link[keyring]{keyring}}
package). Default is "R-REDCapSync".

\if{html}{\out{<div class="sourceCode">}}\preformatted{# check current value package is using...
config$keyring.service()
# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.keyring.service") # get
options(redcapsync.config.keyring.service = "REDCapSync") # set

# set with ennvar (which will be prioritized when options not defined)
Sys.getenv("REDCAPSYNC_CONFIG_KEYRING_SERVICE") # get
Sys.setenv(REDCAPSYNC_CONFIG_KEYRING_SERVICE = "REDCapSync") # set in session
}\if{html}{\out{</div>}}
}

\subsection{openxlsx.header.style}{

Excel sheet header using \code{\link[openxlsx:createStyle]{openxlsx::createStyle()}}

\if{html}{\out{<div class="sourceCode">}}\preformatted{# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.openxlsx.header.style") # get
new_style <- openxlsx::createStyle(fontSize = 12L)
options(redcapsync.config.openxlsx.header.style = new_style)
# does not look up envvar due to it's function type
}\if{html}{\out{</div>}}
}

\subsection{openxlsx.body.style}{

Excel sheet body using \code{\link[openxlsx:createStyle]{openxlsx::createStyle()}}

\if{html}{\out{<div class="sourceCode">}}\preformatted{# set with options (which will be prioritized over envvar)
getOption("redcapsync.config.openxlsx.body.style") # get
new_style <- openxlsx::createStyle(fontSize = 12L)
options(redcapsync.config.openxlsx.body.style = new_style)
# does not look up envvar due to it's function type
}\if{html}{\out{</div>}}
}
}
\section{Option Names (searched first)}{
\if{html}{\out{<div class="sourceCode">}}\preformatted{option_list <- list(
  redcapsync.config.allow.test.names = NULL,
  redcapsync.config.show.api.messages = NULL,
  redcapsync.config.verbose = NULL,
  redcapsync.config.offline = NULL,
  redcapsync.config.cache.dir = NULL,
  redcapsync.config.keyring = NULL,
  redcapsync.config.keyring.service = NULL,
  redcapsync.config.openxlsx.header.style = NULL,
  redcapsync.config.openxlsx.body.style = NULL
)
}\if{html}{\out{</div>}}
}

\section{Environment Variable Names (searched second)}{
\if{html}{\out{<div class="sourceCode">}}\preformatted{envvar_list <- list(
  REDCAPSYNC_CONFIG_ALLOW_TEST_NAMES = NA,
  REDCAPSYNC_CONFIG_SHOW_API_MESSAGES = NA,
  REDCAPSYNC_CONFIG_VERBOSE = NA,
  REDCAPSYNC_CONFIG_OFFLINE = NA,
  R_USER_CACHE_DIR = NA, # affects your entire cache for any package
  REDCAPSYNC_CONFIG_CACHE_DIR = NA, # affects only REDCapSync Cache
  REDCAPSYNC_CONFIG_KEYRING = NA,
  REDCAPSYNC_CONFIG_KEYRING_SERVICE = NA
)
}\if{html}{\out{</div>}}
}

\examples{

# disable with environment variable
Sys.setenv(REDCAPSYNC_CONFIG_OFFLINE = FALSE)

config$offline()

# change to offline
options(redcapsync.config.offline = TRUE)

config$offline()
}
\seealso{
\code{vignette("Projects", package = "REDCapSync")}
\link{setup_project} for initializing projects
}
