From a671c2e9e331a516e7ee20ecb7ed054328953700 Mon Sep 17 00:00:00 2001 From: Rodrigo Basa Date: Tue, 27 Aug 2024 12:55:38 +0200 Subject: [PATCH] ask the use to confirm their action --- DESCRIPTION | 1 + R/utils.R | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/DESCRIPTION b/DESCRIPTION index 4a9a7f3..2d2a133 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,6 +19,7 @@ Imports: box, cli, fs, + glue, rlang Suggests: languageserver, diff --git a/R/utils.R b/R/utils.R index 950a641..8322408 100644 --- a/R/utils.R +++ b/R/utils.R @@ -10,6 +10,16 @@ #' #' @export use_box_lsp <- function(file_path = ".Rprofile") { + response <- readline( + glue::glue("Would you like to create or modify the `{file_path}` file? (yes/No) ") + ) + response <- substr(response, 1, 1) + if (response == "Y" || response == "y") { + overwrite <- TRUE + } else { + cli::cli_abort("`{file_path}` file creation/modification cancelled!") + } + rprofile <- fs::path_package("box.lsp", "Rprofile.R") to_write <- readLines(rprofile)