cloc_call | R Documentation |
cloc.pl
directly with granular control over optionsIt is nigh impossible to predict all use-cases for the cloc.pl
acript and
create associated R functions for them. To that end, this function provides direct
access to the script and enables direct passing of command-line parameters
via processx::run()
.
cloc_call(args = character(), echo = TRUE, ...)
cloc_help(echo = FALSE)
cloc_version(echo = FALSE)
cloc_os(echo = FALSE)
args, |
character vector, arguments to the command. They will be escaped
via |
echo |
echo Whether to print the standard output and error to the screen. Note that the order of the standard output and error lines are not necessarily correct, as standard output is typically buffered. |
... |
other options/parameters passed on to |
the structure returned by processx::run()
(a list with four elements).
As indicated, this is an lower-level function providing granular control over
the options for cloc.pl
. You are invoking an operating system command-line
and need to read the cloc.pl
help very carefully as — unlike the higher-level
functions – there are no "guide railss" provided to do helpful things such as e
nsure you do not clobber files in a given directory.
processx::run()
supports "callback functions" to make it easier to deal with
stdout and stderr and you may need to make use of those depending on the how
you are calling the underlying script.
# Get help on the parameters `cloc.pl` supports
cloc_call("--help", echo_cmd=TRUE, echo=TRUE)
# or use the helper version of the above
cloc_help()
# show the OS type
cloc_call("--show-os")
# shortcut equivalent
cloc_os()
# retrieve the OS type
trimws(cloc_call("--show-os")$stdout)
# shortcut of the above with no echo and only returning trimmed stdout
cloc_os()
# get version of cloc.pl script provided with the package
cloc_version()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.