Sat, 03 May 2008

getopt support for littler

Practically ever since Jeff and I released littler to add easy scripting for R, questions popped up about how to support getopt-alike command-line parsing.

And as of today, a new package r-cran-getopt is in Debian. It provides Allen Day's recently released package getopt from CRAN which provides a new function getopt.

Given a suitable data structure that provides long and short-form command-line option names, whether arguments are mandatory, optional or not required (as for flags), and a data-type, getopt munges the command-line arguments supplied by the user and fills a new variable opt accordingly. If a fifth columns with help text is provided, a usage string can be generated as well.

Thanks to Allen for writing getopt, for accepting a quick two-line patch extending support from Rscript to littler, and for fixing one or two minor bugs. Thanks also to the Debian ftpmasters for adding r-cran-getopt within a few days.

/computers/linux/debian/packages | permanent link