trevorld / r-optparse

command-line optional argument parser
http://trevorldavis.com/R/optparse/dev/
GNU General Public License v2.0
146 stars 11 forks source link

Can optparse accept multiple files (--input file1.txt file2.txt --chip file3.txt file4.txt)? #18

Closed endrebak closed 8 years ago

endrebak commented 8 years ago

This SO answer claims that this is not possible: http://stackoverflow.com/a/13811415/992687 , but the answer is old.

trevorld commented 8 years ago

Exactly like that should not be possible in optparse (should be possible in argparse). However what you could do in optparse do is use a delimiter like ; and use strsplit on the options.

Rscript myprogram.r  --input="file1.txt;file2.txt" --chip="file3.txt;file4.txt"

Alternatively you could set positional_arguments=TRUE and put your multiple files as your positional arguments, you'll then get a character vector of four files.

Rscript myprogram.r file1.txt file2.txt file3.txt file4.txt