#!/usr/bin/env Rscript

# This is a helper script to run the pipeline.
# Choose how to execute the pipeline below.
# See https://books.ropensci.org/targets/hpc.html
# to learn about your options.

'usage:
  run.R all
  run.R target <targets>...
  run.R -h | --help

options:
 -h --help    Show this screen' -> doc

library(docopt)
opts <- docopt(doc)

Sys.setenv("IN_TARGETS" = "true")
Sys.setenv("ALLOW_DOWNLOADS" = "true")

if (opts$all) {
  cli::cli_alert_info("Running all targets.")
  targets::tar_make()
} else {
  cli::cli_alert_info("Running targets: {.and {.field {opts$targets}}}")
  targets::tar_make(targets::any_of(!!opts$targets))
}
# targets::tar_make_clustermq(workers = 2) # nolint
