parse_with_defs {defineOptions} | R Documentation |
Function to parse command line arguments with ParserDef S4 object
Description
parse_with_defs function parses command line arguments.
Usage
## S4 method for signature 'ParserDef,character'
parse_with_defs(obj,cmd_args)
Arguments
obj |
ParserDef S4 object |
cmd_args |
character |
Details
parse_with_defs is a S4 method of ParserDef
class. This
method parses command line options with the definitions of
ParserDef. It returns a list that holds parsed option values,
positional arguments and default values for options not specified.
Value
List (S3 parsed_result class)
values |
list with values. Each element name is defined by def_name. |
opt_specified |
list with boolean values. Each element name is defined by def_name. Boolean values that represent whether the option are specified in command line arguments or not. FALSE means the value is supplied as a default value through callback mechanism. |
positional |
positional arguments. If there are no positional arguments, NA is assigned. |
See Also
ParserDef-class
defineOptions-package
summary.parsed_result
Examples
# In practice, command line arguments can be obtained by commandArgs() function
# with trailingOnly option TRUE.
# command_arguments = commandArgs(trailingOnly = TRUE)
example_string = "input1.txt input2.txt --target-range 60,140 --exclude-weekend --output log.data"
command_arguments = strsplit( example_string, " ")[[1]]
parsed_result = parse_with_defs(parser_def, command_arguments) # parser_def is a ParserDef object