R/commandline.R

Defines functions prep_comArgs prep_alf_frp

Documented in prep_alf_frp prep_comArgs

#' Prepare command line arguments
#'
#' Prepare command line argument inputs in a matrix.
#'
#' @param comArgs output from \code{commandArgs(TRUE)}.
#'
#' @return a matrix.
#' @export
#'
#' @examples
#' # not run
prep_comArgs <- function(comArgs){
  x <- do.call("rbind", strsplit(comArgs, "="))
  options(warn = -1)
  arg.char <- which(is.na(as.numeric(x[, 2])))
  options(warn=0)
  if(length(arg.char) > 0)
    x[arg.char, 2] <- paste0("'", x[arg.char, 2], "'")
  x
}

#' Helper function for FRP processing
#'
#' Helper function for Fire Return Period processing.
#'
#' @param comArgs output from \code{commandArgs(TRUE)}.
#' @param out character, output directory.
#'
#' @return invisible, side effects of creating output directory and \code{sink} message to disk.
#' @export
#'
#' @examples
#' # not run
prep_alf_frp <- function(comArgs, out){
  cat(comArgs)
  pp_frp_stops()
  dir.create(file.path(out, "FRP"), showWarnings = FALSE)
  sink(file = file.path(out, "message.txt"), append = TRUE)
  cat("Below is a link to a preliminary R Shiny Alfresco FRP/FRI results app.\n")
  sink()
  invisible()
}
leonawicz/alfresco documentation built on May 6, 2019, 4:59 p.m.