Utilities for running system commands and tools like git, docker, etc.
These functions leverage sys::exec_internal() to run commands and capture their output.
cmd(): Run a generic command.git(): Run agitcommand.gh(): Run a GitHub CLI (gh) command.docker(): Run adockercommand.
Usage
cmd(cmd, ..., .timeout = 60, .echo = TRUE)
git(cmd, ..., .timeout = 60, .echo = TRUE)
gh(cmd, ..., .timeout = 60, .echo = TRUE)
docker(cmd, ..., .timeout = 60, .echo = TRUE)
npx(cmd, ..., .timeout = 60, .echo = TRUE)Examples
#--- git ---
if (FALSE) { # \dontrun{
# get git version
git("--version")
# git status
git("status")
# git commit
git("commit", "-m", "Initial commit")
} # }
#--- gh ---
if (FALSE) { # \dontrun{
# command used to initialize this repository on github:
gh("repo", "create", "landrise/landrise.utils", "--private", "--source=.", "--remote=upstream")
} # }
# --- docker ---
if (FALSE) { # \dontrun{
# get docker help
docker("--help")
# list docker images
docker("images")
# run a docker container
docker("run", "--rm", "hello-world")
} # }
# --- npx ---
if (FALSE) { # \dontrun{
# get npx help
npx("--help")
# create a new react app
npx("create-react-app", "my-app")
# run repomix tool
npx("repomix", "--help")
} # }
