This function is used to create an instance of a parser object
which when combined with the parse_args(), make_option(), and add_option()
methods is very useful for parsing options from the command line.
Usage
OptionParser(
usage = "usage: %prog [options]",
option_list = list(),
add_help_option = TRUE,
prog = NULL,
description = "",
epilogue = "",
formatter = IndentedHelpFormatter
)Arguments
- usage
The program usage message that will printed out if
parse_args()finds a help option,\%progis substituted with the value of theprogargument.- option_list
A list of of
OptionParserOptioninstances that will define howparse_args()reacts to command line options.OptionParserOptioninstances are usually created bymake_option()and can also be added to an existingOptionParserinstance via theadd_option()function.- add_help_option
Whether a standard help option should be automatically added to the
OptionParserinstance.- prog
Program name to be substituted for
\%progin the usage message (including description and epilogue if present), the default is to use the actual Rscript file name if called by an Rscript file and otherwise keep\%prog.- description
Additional text for
print_help()to print out between usage statement and options statement- epilogue
Additional text for
print_help()to print out after the options statement- formatter
A function that formats usage text. The function should take only one argument (an
OptionParser()object). Default isIndentedHelpFormatter(). The other builtin formatter provided by this package isTitledHelpFormatter().
References
Python's optparse library, which inspired this package,
is described here: https://docs.python.org/3/library/optparse.html