cmd_options {photon} | R Documentation |
Format command line options
Description
Helper function to format options for command line calls. The function accepts key-value pairs where the parameter name is the name of the option and the parameter value is the value of the option. Arguments are formatted according to the following rules:
If a value is
TRUE
, add parameter name as flag.If a value is
FALSE
, do not add parameter name as flag.If a value has
length(x) > 1
, collapse it as a CSV.If a parameter name is missing, take the value as the flag name.
If a parameter name is given, replace underscores with hyphens.
Usage
cmd_options(..., use_double_hyphens = FALSE)
Arguments
... |
Key-value pairs of command line options. |
use_double_hyphens |
If |
Value
A character vector of formatted command line options that can
be used as input to system2
or run
.
Examples
# converts R parameters to CMD options
# parameters for the ping command
cmd_options(n = 1, w = 5, "127.0.0.1")
# sometimes, it is necessary to use double hyphens
# options for the docker ps command
cmd_options("ps", all = TRUE, format = "json", use_double_hyphens = TRUE)
# particularly useful together with photon
# the following options can be used for the `photon_opts` argument
# of photon$start()
cmd_options(cors_any = TRUE, data_dir = "path/to/dir")