]> nmode's Git Repositories - Rnaught/blobdiff - R/app.R
Prompt user to install optional dependency
[Rnaught] / R / app.R
diff --git a/R/app.R b/R/app.R
index feb052f3d69d9e66a079716305abc7b860b48d6a..945f9e4634d61a2052d3d0ccde41071959b18d54 100644 (file)
--- a/R/app.R
+++ b/R/app.R
@@ -1,9 +1,19 @@
 #' Launch the Rnaught Web Application
 #'
 #' Launch the Rnaught Web Application
 #'
+#' @importFrom utils install.packages
+#'
 #' @export
 app <- function() {
 #' @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)
 }
 }