run_well: A wrapper to run system commands well

View source: R/run_well.r

run_wellR Documentation

A wrapper to run system commands well

Description

This function is a wrapper for ⁠\link{[processx]{run}}⁠, with opinionated error handling. It will return the result of stdin if possible, and give errors about timeouts and stderr otherwise.

Usage

run_well(
  command,
  args = character(),
  split_args = TRUE,
  capture_error = FALSE,
  ...
)

Arguments

command

Character scalar, the command to run. If you are running .bat or .cmd files on Windows, make sure you read the 'Batch files' section in the process manual page.

args

Character vector, arguments to the command.

split_args

(logical; default = TRUE) split the args string into a vector on spaces (because that's how processx::run expects it)?

capture_error

(logical; default = FALSE) return stderr as a character vector?

...

other arguments passed to ⁠\link{[processx]{run}}⁠.

Value

a character vector of stdout

Examples

## Not run: 
# Where is R (hopefully on your path)?
run_well("where.exe", "R")

# Where is are (hopefully nowhere)?
run_well("where.exe", "are")

## End(Not run)

baslat/sak documentation built on April 14, 2025, 4:14 p.m.