docopt / docopt.R

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

missing options are either NULL or list() depending on "Options:" section #21

Open mmuurr opened 8 years ago

mmuurr commented 8 years ago

Here are 4 docopt docs, and an option-less call results in the same 4 outputs for all cases in the reference implementation... but in the R package one of the docs results in list() instead of NULL.

Case 1 :

doc <- "
prog
Usage:
  prog [(--foo=X --bar=X)]
"
str(docopt::docopt(doc, "", strict = TRUE))
 List of 2
  $ --foo: NULL
  $ --bar: NULL
  - attr(*, "class")= chr [1:2] "docopt" "list"

Case 2:

doc <- "
prog
Usage:
  prog [(--foo=X --bar=X)]
Options:
  --foo=X  some description
  --bar=X  some other description
"
str(docopt::docopt(doc, "", strict = TRUE))
 List of 2
  $ --foo: NULL
  $ --bar: NULL
  - attr(*, "class")= chr [1:2] "docopt" "list"

Case 3:

doc <- "
prog
Usage:
  prog [options] [(--foo=X --bar=X)]
"
str(docopt::docopt(doc, "", strict = TRUE))
 List of 2
  $ --foo: list()
  $ --bar: list()
  - attr(*, "class")= chr [1:2] "docopt" "list"

Case 4:

doc <- "
prog
Usage:
  prog [options] [(--foo=X --bar=X)]
Options:
  --foo=X  some description
  --bar=X  some other description
"
str(docopt::docopt(doc, "", strict = TRUE))
 List of 2
  $ --foo: NULL
  $ --bar: NULL
  - attr(*, "class")= chr [1:2] "docopt" "list"

Cases 1, 2, and 4 give --foo and --bar as NULL. Case 3 give --foo and --bar as list(). The Python reference implementation gives null for all four cases.