r - Can't pass two numerical arguments with docopt package -
in creating command line tool using r, decided use docopt package. works passing flags, can't figure out how pass 2 numeric values. see below code:
#! /usr/bin/rscript 'usage: ./test.r [-lr <low> -hr <high>] options: -h --help shows screen -lr --low <low> passes low risk investiment -hr --high <high> passes high risk investiment' -> doc library(docopt) # retrieve command-line arguments opts <- docopt(doc) # options? note stripped versions of parameters added returned list cat(opts$high) cat(opts$low) str(opts)
whenever try run using ./test.r -lr 2000 -hr 4000
warns me methods package being loaded , returns nothing else.
- what mistake here?
first, -h
specified twice: once "help", "high", you'll run problems there. fix this, i'll use upper-case letters short arguments. second, argument option must either in <angular-brackets>
or upper-case, -lr
doesn't work. (apparently needs space between option , argument.) i'll expand same named arguments long options.
additionally (though perhaps not strictly required), think comma helps clarify things. (edit: apparently docopt.r
doesn't leading ./
on usage, i've updated output.)
usage: test.r [-l <low> -h <high>] options: -h, --help shows screen -l <low>, --low <low> passes low risk investiment -h <high>, --high <high> passes high risk investiment
(i found requirements docopt
@ http://docopt.org/. found interactive docopt demo worked quite well, too.)
Comments
Post a Comment