From 1d15746821b536ef60d6b86e475bf0057d98e8bd Mon Sep 17 00:00:00 2001 From: Naeem Model Date: Tue, 25 Jul 2023 01:50:09 +0000 Subject: Prompt user to install optional dependency --- R/app.R | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'R/app.R') diff --git a/R/app.R b/R/app.R index feb052f..945f9e4 100644 --- a/R/app.R +++ b/R/app.R @@ -1,9 +1,19 @@ #' Launch the Rnaught Web Application #' +#' @importFrom utils install.packages +#' #' @export app <- function() { - if (!requireNamespace("shiny", quietly = TRUE)) - stop("The package 'shiny' must be installed to launch the Rnaught web application.") + if (!requireNamespace("shiny", quietly = TRUE)) { + answer <- readline(paste0("The package 'shiny' must be installed to ", + "launch the Rnaught web application.\nWould you like to install it? ", + "[Y/n] ")) + + if (answer == "Y" || answer == "y") + install.packages("shiny") + else + stop("Aborting.", call. = FALSE) + } - shiny::shinyApp(ui, server) + shiny::shinyApp(ui(), server) } -- cgit v1.2.3