From bf765bfae639080431900ff7affc2be7bca6b06f Mon Sep 17 00:00:00 2001
From: Johannes Boog <johannesboog@yahoo.de>
Date: Tue, 26 Oct 2021 15:05:36 +0200
Subject: [PATCH] [base] option to limit benchmark script generation to
 provided list of PRJ files

---
 R/generate_benchmark_script.R | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/R/generate_benchmark_script.R b/R/generate_benchmark_script.R
index 3cc66fa..17e92a6 100644
--- a/R/generate_benchmark_script.R
+++ b/R/generate_benchmark_script.R
@@ -10,6 +10,7 @@
 #' @inheritParams ogs6_generate_benchmark_script
 #' @param starting_from_prj_path string: Optional: `.prj` path to start from
 #' @param skip_prj_paths character: Optional: `.prj` paths to skip
+#' @param only_prj_files character: Optional: `.prj` files to limit to.
 #' @export
 ogs6_generate_benchmark_scripts <-
     function(path,
@@ -18,7 +19,8 @@ ogs6_generate_benchmark_scripts <-
              read_in_gml,
              read_in_vtu = FALSE,
              starting_from_prj_path = "",
-             skip_prj_paths = character()){
+             skip_prj_paths = character(),
+             only_prj_files = character()){
 
     if(missing(path)){
         path <- unlist(options("r2ogs6.default_benchmark_path"))
@@ -40,6 +42,7 @@ ogs6_generate_benchmark_scripts <-
     script_path <- as_dir_path(script_path)
     assertthat::assert_that(assertthat::is.string(starting_from_prj_path))
     assertthat::assert_that(is.character(skip_prj_paths))
+    assertthat::assert_that(is.character(only_prj_files))
 
     prj_paths <- list.files(path = path,
                             pattern = "\\.prj$",
@@ -78,6 +81,12 @@ ogs6_generate_benchmark_scripts <-
             next
         }
 
+        if(!(missing(only_prj_files))){
+            if(!(basename(prj_paths[[i]]) %in% only_prj_files)){
+                next
+            }
+        }
+
         # cat("\nGenerating script from path", prj_paths[[i]])
 
         # Put simulations in their own subfolders under sim_path
-- 
GitLab