Asserts that a command-line interface (CLI) tool is found on the system's
PATH and returns the executable's filesystem path.
Usage
assert_cli(
cmd,
error_msg =
paste0("The {.strong {cmd}} executable is required but couldn't be found on ",
"system's {.href [PATH](https://en.wikipedia.org/wiki/PATH_(variable))}."),
force_which = FALSE
)Arguments
- cmd
System command to invoke the CLI tool. A character scalar.
- error_msg
Error message to print in case
cmdis not found on system'sPATH. Supports cli's inline markup. A character scalar.- force_which
If set to
TRUE,base::Sys.which(), which relies on the system commandwhich, will be used instead ofcommand -vto determine the availability ofcmdon Unix-like systems. On Windows,base::Sys.which()is used in any case.command -vis generally recommended for bourne-like shells and therefore is the default on Linux, macOS and other Unixes.
Value
If the CLI tool is available on the system's PATH, its filesystem path, invisibly. Otherwise, an error is thrown.
See also
Other system interaction functions:
test_cli()
Other functions extending the checkmate package:
assert_class_any(),
assert_df_or_tibble(),
assert_inf_count()
