-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsitrep.R
More file actions
61 lines (57 loc) · 1.8 KB
/
sitrep.R
File metadata and controls
61 lines (57 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#' Output an environment status situation report
#'
#' Reports on the availability of certain features of your compute
#' infrastructure, for example, environment variables, or a specific RStudio
#' Package Manager instance. Configure the tests with the `use_envstat` and
#' `edit_envstat` functions.
#'
#' @param silent boolean disables printed output
#' @param path path to the envstat config file
#' @return TRUE/FALSE invisibly, to indicate all checks pass/fail
#' @export
#' @examples
#' \dontrun{
#' # By default envstat uses a config file in your home directory
#' envstat::sitrep()
#'
#' # But you can tell it to use a different config file if you prefer
#' envstat::sitrep(path = "/tmp/config.yml")
#'
#' # sitrep can also run silently, so that it can be used programatically
#' envstat::sitrep(silent = TRUE)
#' }
sitrep <- function(silent = FALSE, path = "~/.envstat") {
cli_silencer(
silent, "cli_h1",
"envstat situation report"
)
envstatconf <- read_config(path = path)
output_files <- check_files(envstatconf, silent = silent)
output_dirs <- check_dirs(envstatconf, silent = silent)
output_env_vars <- check_env_vars(envstatconf, silent = silent)
output_rspm <- check_rspm(envstatconf, silent = silent)
output_rsc <- check_rsc(envstatconf, silent = silent)
output_repos <- check_repos_available(envstatconf, silent = silent)
all_outputs <- c(
output_files,
output_dirs,
output_env_vars,
output_rspm,
output_rsc,
output_repos
)
cli_silencer(silent, "cli_h2", "Final result")
if (FALSE %in% all_outputs) {
cli_silencer(
silent, "cli_alert_danger",
"Some checks failed, please review the output above"
)
invisible(FALSE)
} else {
cli_silencer(
silent, "cli_alert_success",
"All checks passed!"
)
invisible(TRUE)
}
}