doc <- "
My Program
Usage:
progname [options] doit --reqarg <arg1>
Options:
--opt1 <val>
"
The reference implementation supports leading options, as described in the above docopt doc.
The R implementation errs:
docopt::docopt(doc, c("doit", "--reqarg", "arg1val"), strict = TRUE) ## errs, but shouldn't
Moving [options]
to the end fixes this, but there are lots of good use cases where users are encouraged to specify 'global' options prior to the subcommands (e.g. optional args like, --env prod
).