Parse command line arguments.
# install.packages("pak")
pak::pak("devOpifex/cl.args")#!/usr/bin/Rscript
library(cl.args)
cl <- cl.make(
name = "Test",
version = "1.0.0"
)
name <- cl$str("name", "Bob", "A name")
n <- cl$int(
name = "n",
default = 42,
description = "An age"
)
# prints help (and quits) if -help is passed
cl$help()
erratum::resolve(n)
erratum::resolve(m)
cat(sprintf("Hello %s, you are %d years old.\n", name, n))Which you can then call like ./script.R
Accepts arguments as:
-name=Bob-name Bob-nameOnly for booleans-helpPrints help and quits, autogenerated