View source: R/parse_all_named_cli_args.R
parse_all_named_cli_args | R Documentation |
Add an arbitrary number of CLI args to a parser (default trailing args only), then assign to a chosen environment (default 'globalenv()'). By default, automatically assign logical and integer data types when they are detected among CLI arguments, e.g. 'true' is assigned as 'TRUE' and 5 is assigned as '5L'.
parse_all_named_cli_args(
required_args = NULL,
trailingOnly = TRUE,
assign_logical = TRUE,
assign_integer = TRUE,
assign_NA = TRUE,
assign_NULL = TRUE,
split_comma_str = TRUE,
allow_rebinding = TRUE,
assignment_env = globalenv()
)
required_args |
[list] (optional; default = NULL) Named list of required arguments to parse, with data types if desired. If you do not wish to check data types, supply 'NA'. e.g. 'list(arg1 = "character", arg2 = NA)'. **NOTE:** Parsed args are all "character" by default. If you wish the parser to assign integer or logical data types, set 'assign_integer' or 'assign_logical' to 'TRUE', and then you may check those types as well. |
trailingOnly |
[lgl] if TRUE, only the trailing arguments are used - passed to 'commandArgs()' |
assign_logical |
[lgl] if TRUE, assign true/false in parsed args to 'TRUE'/'FALSE' |
assign_integer |
[lgl] if TRUE, assign solely numeric args to integer e.g. 5 to '5L' |
assign_NA |
[lgl] if TRUE, assign 'NA' in parsed args to 'NA' |
assign_NULL |
[lgl] if TRUE, assign 'NULL' in parsed args to 'NULL' |
split_comma_str |
[lgl] if TRUE, split comma-separated strings into vectors |
allow_rebinding |
[lgl] if TRUE, allow re-binding of variables in the chosen environment (i.e. lockBinding was already used - unlock and re-lock all passed args, if relevant) |
assignment_env |
[env] which environment to assign CLI arguments to as named variables |
This does not take advantage of argument defaults or types. See https://github.com/trevorld/r-argparse for documentation.
[named list] named list of CLI arguments
Other job_submission:
submit_job()
## Not run:
cli_args <- parse_all_named_cli_args(
trailingOnly = TRUE,
assign_logical = TRUE,
assign_integer = TRUE,
assign_NA = TRUE,
assign_NULL = TRUE,
assignment_env = globalenv()
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.