run_command {rpymat} | R Documentation |
Execute command with additional environments
Description
Enables 'conda' environment
Usage
cmd_create(command, shell, use_glue = TRUE)
cmd_set_env(command, key, value, quote = TRUE, quote_type = "cmd")
cmd_set_workdir(command, workdir)
cmd_set_conda(command, conda_path, env_path)
cmd_build(command, .env = parent.frame(), ...)
detect_shell(suggest = NULL)
run_command(
command,
shell = detect_shell(),
use_glue = FALSE,
enable_conda = TRUE,
stdout = "",
stderr = "",
stdin = "",
input = NULL,
env_list = list(),
wait = TRUE,
timeout = 0,
...,
workdir = getwd(),
dry_run = FALSE,
print_cmd = dry_run,
glue_env = parent.frame()
)
Arguments
command |
system command |
shell |
shell type |
use_glue |
whether to |
key , value |
environment variable key and value |
quote , quote_type |
whether to quote the environment variables and
what quote type should use; see |
workdir |
the working directory |
conda_path |
'conda' path; default is |
env_path |
'conda' environment path; default is |
suggest |
suggested shell type; default is |
enable_conda |
whether to activate 'conda' |
stdout , stderr , stdin , input , wait , timeout , ... |
passed to
|
env_list |
a key-value pairs of environment variables |
dry_run |
whether to dry-run the command (do not execute, simply returns the command), useful to debug |
print_cmd |
whether to print the command out |
glue_env , .env |
the environment to evaluate variables when |
Value
All the functions return a list with class
rpymat_system_command
except for
run_command
, which returns the exit code by system2
.
Examples
run_command("conda install -y numpy", dry_run = TRUE)
a <- "This is a message"
run_command('echo "{a}"', dry_run = TRUE,
enable_conda = FALSE, use_glue = TRUE)
## Not run:
# Use `jupyter_launch()` instead. This is just a demonstration
run_command('"{jupyter_bin()}" server list', use_glue = TRUE)
## End(Not run)