Execute Native Scripts

Run complex native scripts with a single command, similar to system commands.


CRAN_Status_Badge GitHub release Build Status AppVeyor Build Status codecov
License Downloads Rdoc

Overview

The purpose of the scriptexec package is to enable quick and easy way to execute native scripts.

Usage

Simply load the library and invoke the execute

library(scriptexec)
 
# execute script text
output <- scriptexec::execute("echo command1\necho command2")
expect_equal(output$status, 0)
expect_equal(grepl("command1", output$output), TRUE)
expect_equal(grepl("command2", output$output), TRUE)
 
if (.Platform$OS.type == "windows") {
    ls_command <- "dir"
} else {
    ls_command <- "ls"
}
output <- scriptexec::execute(c("echo user home:", ls_command))
expect_equal(output$status, 0)
 
# execute multiple commands as a script
output <- scriptexec::execute(c("cd", "echo test"))
expect_equal(output$status, 0)
 
# pass arguments (later defined as ARG1, ARG2, ...) and env vars
if (.Platform$OS.type == "windows") {
    command <- "echo %ARG1% %ARG2% %MYENV%"
} else {
    command <- "echo $ARG1 $ARG2 $MYENV"
}
output <- scriptexec::execute(command, args = c("TEST1", "TEST2"), env = c("MYENV=TEST3"))
expect_equal(output$status, 0)
expect_equal(grepl("TEST1 TEST2 TEST3", output$output), TRUE)
 
# non zero status code is returned in case of errors
expect_warning(output <- scriptexec::execute("exit 1"))
expect_equal(output$status, 1)
 
# do not wait for command to finish
output <- scriptexec::execute("echo my really long task", wait = FALSE)
expect_equal(output$status, -1)

Installation

Install from CRAN:

install.packages("scriptexec")

Install latest release from github:

devtools::install_github("sagiegurari/[email protected]")

Install current development version from github (might be unstable):

devtools::install_github("sagiegurari/scriptexec")

API Documentation

See full docs at: API Docs

Contributing

See contributing guide

Release History

See NEWS

License

Developed by Sagie Gur-Ari and licensed under the Apache 2 open source license.

News

CHANGELOG

0.3.1

  • Update dependencies #31
  • Support 100% converage regardless of OS
  • Update windows build as building R dependencies is unstable

0.3.0

  • Fixed bug which caused incorrect command line arguments setup #30
  • Make travis mac builds optional as R support for mac on travis is unstable

0.2.3

  • Add execute errors to output structure #27
  • Add all dev dependencies to suggest field #23
  • Share example code in unit test, readme and vignettes #21
  • Add linter unit test #20
  • Fix tests to pass on all platforms #24
  • Fix example unit test #19
  • Script output key checks in api stability unit tests #22
  • Automatically test all demos
  • Run mac build in travis #28
  • Test specific R version in travis build
  • More demos #25

0.2.2

  • Output executed script #16
  • Packrat integration to enable easier collaboration #14
  • Generate readme dynamically #17
  • Document only execute api in generated docs #15

0.2.1

  • Support custom runner #9
  • Support env vars for windows platform #11
  • Support flag to print every command before invocation #12
  • Markdown documentation hosted on github #10
  • Consistent error handling for all platforms

0.2.0

  • execute_script function renamed to execute
  • Add support for command line arguments to be passed to the script #1
  • Merge all output text instead of vector #5
  • Add status 0 instead of null #6
  • Pass env variables as part of script execution #7
  • Add wait support #8
  • Export all functions #4
  • Add demos #3

0.1.0

  • Initial Release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("scriptexec")

0.3.1 by Sagie Gur-Ari, 6 months ago


https://github.com/sagiegurari/scriptexec


Report a bug at https://github.com/sagiegurari/scriptexec/issues


Browse source code at https://github.com/cran/scriptexec


Authors: Sagie Gur-Ari [aut, cre]


Documentation:   PDF Manual  


Apache License 2.0 license


Suggests knitr, testthat, lintr, formatR, devtools, roxygen2, rmarkdown, Rd2md


See at CRAN