Parsing command-line arguments by Getopt::Long


library(knitr)
knitr::opts_chunk$set(
    error = FALSE,
    tidy  = FALSE,
    message = FALSE,
    comment = NA,
    fig.align = "center")
library(GetoptLong)
get_os <- function(){
  sysinf <- Sys.info()
  if (!is.null(sysinf)){
  os <- sysinf['sysname']
  if (os == 'Darwin')
    os <- "osx"
  } else { ## mystery machine
    os <- .Platform$OS.type
    if (grepl("^darwin", R.version$os))
      os <- "osx"
    if (grepl("linux-gnu", R.version$os))
      os <- "linux"
  }
  tolower(os)
}

is.solaris = function() {
  os = get_os()
  !(os %in% c("windows", "unix", "linux", "osx"))
}

if(is.solaris()) {
  cat("**GetoptLong** is not supported on Solaris platform.\n")
} else {
  if(!is.solaris()) {
      invisible(knit("GetoptLong.Rmd2", "GetoptLong.md2"))
  }

  if(Sys.info()["user"] == "jokergoo") {
      invisible(file.copy("GetoptLong.md2", "/Users/jokergoo/project/GetoptLong/vignettes/GetoptLong.md2", overwrite = TRUE))
  }

  ln = readLines("GetoptLong.md2")
  cat(paste(ln, collapse = "\n"))
}


Try the GetoptLong package in your browser

Any scripts or data that you put into this service are public.

GetoptLong documentation built on Jan. 8, 2021, 2:29 a.m.