Commit 4dbc7bf7 authored by gohr's avatar gohr

adds argument --yes

parent 6cb89686
......@@ -52,6 +52,7 @@ Options:
--resprefix <name> Sets a custom `results_prefix` variable for the script which can be used to prefix results
files. The default is the name of the R-script
--keep Keep generated Rmd and md files
--yes Assume user answer to be Yes when script has changed and data will be overwritten
'
opts <- docopt(doc, args=rendrArgs)
......@@ -59,6 +60,7 @@ opts <- docopt(doc, args=rendrArgs)
r_script <- opts$r_script
keep_markdown_files <- as.logical(opts$keep)
user_answer_is_yes <- as.logical(opts$yes)
if(!file.exists(r_script)){
......@@ -99,7 +101,12 @@ diffFile(recent_script, r_script, mode = "sidebyside")
if(row_diff > 0) {
cat(red("ATTENTION: the script has been changed. Would you like to overwrite the existing data? [Yes/No] "))
inp <- readLines(file("stdin"), n = 1L)
if(user_answer_is_yes){
cat("Assuming user answer is Yes because argument --yes given. ")
inp="Yes"
}else{
inp <- readLines(file("stdin"), n = 1L)
}
if (!inp == "Yes" & !inp %in% "No") {
stop("ATTENTION: incorrect input provided")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment