make_option | R Documentation |
add_option
adds a option to a prexisting OptionParser
instance
whereas make_option
is used to create a list of
OptionParserOption
instances that will be used in the
option_list
argument of the OptionParser
function to create a
new OptionParser
instance.
make_option(
opt_str,
action = NULL,
type = NULL,
dest = NULL,
default = NULL,
help = "",
metavar = NULL,
callback = NULL,
callback_args = NULL
)
add_option(
object,
opt_str,
action = NULL,
type = NULL,
dest = NULL,
default = NULL,
help = "",
metavar = NULL,
callback = NULL,
callback_args = NULL
)
opt_str |
A character vector containing the string of the desired long flag comprised of “–” followed by a letter and then a sequence of alphanumeric characters and optionally a string of the desired short flag comprised of the “-” followed by a letter. |
action |
A character string that describes the action |
type |
A character string that describes specifies which data type
should be stored, either “logical”, “integer”, “double”,
“complex”, or “character”. Default is “logical” if
|
dest |
A character string that specifies what field in the list returned
by |
default |
The default value |
help |
A character string describing the option to be used by
|
metavar |
A character string that stands in for the option argument when
printing help text. Default is the value of |
callback |
A function that executes after the each option value is fully
parsed. It's value is assigned to the option and its arguments are
the option S4 object, the long flag string, the value of the option,
the parser S4 object, and |
callback_args |
A list of additional arguments passed to callback function (via |
object |
An instance of the |
Both make_option
and add_option
return instances of
class OptionParserOption
.
Trevor Davis.
Python's optparse
library, which inspires this package,
is described here: https://docs.python.org/3/library/optparse.html
parse_args
OptionParser
make_option("--longflag")
make_option(c("-l", "--longflag"))
make_option("--integer", type = "integer", default = 5)
make_option("--integer", default = as.integer(5)) # same as previous
# examples from package vignette
make_option(c("-v", "--verbose"), action = "store_true", default = TRUE,
help = "Print extra output [default]")
make_option(c("-q", "--quietly"), action = "store_false",
dest = "verbose", help = "Print little output")
make_option(c("-c", "--count"), type = "integer", default = 5,
help = "Number of random normals to generate [default %default]",
metavar = "number")
make_option("--generator", default = "rnorm",
help = "Function to generate random deviates [default \"%default\"]")
make_option("--mean", default = 0,
help = "Mean if generator == \"rnorm\" [default %default]")
make_option("--sd", default = 1, metavar = "standard deviation",
help = "Standard deviation if generator == \"rnorm\" [default %default]")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.