diff --git a/README.md b/README.md index 75ff36e..69a7b2c 100644 --- a/README.md +++ b/README.md @@ -152,9 +152,8 @@ HTML notebook that will be saved to the same directory with the extension docker run --rm \ --env-file .env \ -v $(pwd)/notebooks:/data \ - -e RENDER_INPUT="/data/examples/notebook.Rmd" \ - tschaffter/rstudio \ - render + tschaffter/rstudio:4.0.5 \ + render /data/examples/notebook.Rmd ``` ## Versioning diff --git a/root/render.R b/root/render.R index 2982992..89a9f0d 100644 --- a/root/render.R +++ b/root/render.R @@ -1,10 +1,14 @@ -# Renders a notebook in HTML or PDF format using args specified as environment -# variables. +# Render an Rmd notebook to HTML or PDF. +# +# TODO: Use a library for managing command-line options. -input = Sys.getenv("RENDER_INPUT", unset = NA) +# input = Sys.getenv("RENDER_INPUT", unset = NA) output_format = Sys.getenv("RENDER_OUTPUT_FORMAT", unset = "html_document") quiet = Sys.getenv("RENDER_QUIET", unset = "TRUE") +options <- commandArgs(trailingOnly = TRUE) +input <- options[1] + if (is.na(input)) { stop("The environment variable RENDER_INPUT is required") } diff --git a/root/usr/local/bin/render b/root/usr/local/bin/render index b05db99..e69884b 100755 --- a/root/usr/local/bin/render +++ b/root/usr/local/bin/render @@ -1,5 +1,7 @@ #!/bin/bash +# +# Render an Rmd notebook to HTML or PDF. set -euo pipefail -Rscript /render.R \ No newline at end of file +Rscript /render.R "$@" \ No newline at end of file