docopt / docopt.R

Command-line interface description language for R (http://docopt.org)
Other
210 stars 17 forks source link

adding [options] breaks required combinations #22

Open mmuurr opened 8 years ago

mmuurr commented 8 years ago

This is likely related to #21.

doc1 <- "
prog
Usage:
  prog [(--foo=X --bar=Y)]
"
doc2 <- "
prog
Usage:
  prog [options] [(--foo=X --bar=Y)]
"

This call errors as expected:

> str(docopt::docopt(doc1, "--foo=bar", strict = TRUE))
 Error:
  usage: prog [(--foo=X --bar=Y)]

This call succeeds as expected:

> str(docopt::docopt(doc1, "--foo=bar --bar=foo", strict = TRUE))
 List of 2
  $ --foo: chr "bar"
  $ --bar: chr "foo"
  - attr(*, "class")= chr [1:2] "docopt" "list"

This call should error, but doesn't:

> str(docopt::docopt(doc2, "--foo=bar", strict = TRUE))
 List of 2
  $ --foo: chr "bar"
  $ --bar: list()
  - attr(*, "class")= chr [1:2] "docopt" "list"