Description Usage Arguments Details Note Examples
This method provides an interface for creating a single argument. While it is not recommended for use in production ready code, this allows any user to illustrate the creation of individual parser components and may potentially speed up interpretation for scripts of 1 - 2 arguments by avoiding the need for an interface to the R6 class. However, it is still recommended to interact with the standard interface outside of visualizing the methodology.
1 2 3 4 5 6 7 8 9 10 11 |
sflag |
smallest flag |
lflag |
longest flag |
name |
name of the argument. This becomes the name of any parsed argument and is used for extracting by name. If null lflag is used instead. |
narg |
argument for deciding the behaviour when passed multiple arguments. See details for more information. |
For those familiar with the argparse
package in python the narg
argument works in a very similar fashion to
narg
in their package with a few extensions.
The valid options are "?", "*", "+", "N", "N+" and "N-". The first four works
exactly the same, while the latter two provides some addditional options for
"at least" and "at most" N arguments.
narg = "?"
indicates that we accept either 0 or 1 argument.
narg = "*"
indicates that any number of arguments (0, 1, 2, ...)
are accepted
narg = "+"
indicates that require at least 1 argument.
narg = "N"
(where N is an integer) indicates that we accept N and
only N arguments
narg = "N+"
indicates that we accept N or more arguments
but not less
narg = "N-"
indicates that we accepted N or less arguments.
Note that an argument with narg = "+"
and required = FALSE
is
equivalent to specifying narg = "*"
. For narg = "N"
and
narg = "N+"
specifying required = FALSE
will have an effect
similar to "?"
and "+"
but starting from "N"
. Eg. we require either 0
arguments, "N"
or "N+"
arguments.
As a slight note this does mean that narg = 1
is equivalent to narg = "?"
as the behaviour is fully controlled by required = TRUE/FALSE
.
If the argument is a flag (indicated by setting flag = TRUE
) both narg
and required
are ignored internally.
FIX ME:: add description of remaining arguments:
if nchar(sflag) > nchar(lflag) the arguments are switched internally.
1 2 3 4 5 6 7 8 9 10 | # Create a simple argument and extract it's values.
f <- createArgument('h', 'help', 'help', 3, TRUE, FALSE)
getflags(f)
getsflag(f)
getlflag(f)
getnarg(f)
getnargparsed(f)
isflag(f)
isrequired(f)
getname(f)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.