docopt.R icon indicating copy to clipboard operation
docopt.R copied to clipboard

leading [options] doesn't match reference implementation

Open mmuurr opened this issue 4 years ago • 0 comments

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).

mmuurr avatar Aug 18 '21 17:08 mmuurr