docopt / docopt.R

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

[Enquiry] Can't pass two numerical arguments with docopt package #32

Closed lf-araujo closed 5 years ago

lf-araujo commented 7 years ago

In creating a command line tool using R, I decided to use the docopt package. It works for passing flags, but I can't figure out how to pass two numeric values. See the below code:

#! /usr/bin/Rscript
'
 usage: 
 ./test.R [-L <low> -H <high>]

 options:
 -h --help                 Shows this screen
 -L <low>, --low <low>     Passes low risk investiment
 -H <high>, --high <high>  Passes high risk investiment

' -> doc

library(docopt)
# retrieve the command-line arguments
opts <- docopt(doc)
# what are the options? Note that stripped versions of the parameters are added to the returned list
cat(opts$high)
cat(opts$low)
str(opts) 

Whenever I try to run using ./test.R -L 2000 -H 4000 it warns me that the methods package is being loaded and returns nothing else.

lf-araujo commented 7 years ago

I found the error. The R iteration of docopt does not handle the ./test.R at the usage section.

crazyhottommy commented 5 years ago

so how should you do it?