R/command-utils.R

Defines functions parse_command process_command

Documented in parse_command process_command

#' Parsing command
#'
#' @description
#' Function parses command given by user
#' @export

parse_command = function() {
  option_config =
    optparse::make_option(c("-c", "--config",
                            type = "character",
                            default = NULL,
                            help = "YAML config filename"))
  opt_parser =
    optparse::OptionParser(option_list = list(option_config))
  list(
       options = optparse::parse_args(opt_parser),
       parser = opt_parser)
}


#' Process command
#'
#' @description
#' Function processes terminal command given by user.
#' @export

process_command = function(.command) {
  if(is.null(.command$options$config)) {
    optparse::print_help(.command$parser)
    cli::cli_alert_danger("Config file must be supplied.")
    stop()
  }
}
warbarbye/cecs-benchmark documentation built on March 10, 2020, 12:09 a.m.