Description Usage Arguments Details Value Examples
Parser of command-line parameters in BIOS style
Test whether the given option is present in the command line or not
1 2 3 | argParse(optargs, reqargs, usage = paste(scriptName(), "-h"), strict = TRUE)
argPresent(opt)
|
optargs |
String describing optional arguments. Syntax: |
reqargs |
String describining required arguments. Syntax: |
usage |
A character string to be printed if the command-line option parsing fails |
strict |
Logical, are extra un-prefixed parameters allowed? If set to |
opt |
Character string, option name |
argParse
must be called before argGet
,argGetPos
, argPresent
, or argGetDefault
. It checks whether the command line syntax agrees
with the specification of optargs
and reqargs
. If not,
the usage
message is printed and the program exists.
argPresent
returns a boolean value indicating whether the option is present or not.
If the syntax was found correct, argGetPos
can be called to
fetch the ind
th value of the option opt
(indexing from 1). For instance,
if the following option -ranges 3 5
is defined,
argGetPos(“range”, 2) returns 5
. argGet
is
a shortcut to fetch the first element. If the opt is missing, the
default
value will be returned.
argParse
is used for the side effects. If strict
is set to
TRUE
, an invisible NULL
is returned; otherwise, extra
un-prefixed parameters are returned as an invisible character vector
argGet
and argGetPos
returns a character
string. argPresent
returns a boolean value.
In case of any error (wrong syntax, or not-existing option) the R session quits while printing the error message.
1 2 3 4 5 6 7 | ## Not run:
argParse("verbose threshold,2", "infile outfile",
usage="prog [-infile ]infile [-outfile ]outfile [-verbose] [-threshold MIN MAX]")
argIsInit()
argPresent("verbose")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.