#' Install the command line interface
# Inspired by: https://github.com/ankane/jetpack/blob/master/R/cli.R
#' @export
#' @examples \dontrun{
#' showpackage::cli()
#' }
cli <- function() {
if (.Platform$OS.type != "unix") {
file <- "C:/ProgramData/showpackage/bin/showpackage.cmd"
rscript <- file.path(R.home("bin"), "Rscript.exe")
dir <- dirname(file)
if (!file.exists(dir)) {
dir.create(dir, recursive=TRUE)
}
write(paste0("@", rscript, " -e \"showpackage::run()\" %* "), file = file)
message(paste("Wrote", windowsPath(file)))
message(paste0("Be sure to add '", windowsPath(dir), "' to your PATH"))
} else {
file <- "/usr/local/bin/showpackage"
write("#!/usr/bin/env Rscript\n\nshowpackage::run()", file = file)
Sys.chmod(file, "755")
message(paste("Wrote", file))
}
}
windowsPath <- function(path) {
gsub("/", "\\\\", path)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.