From 81c609638bd3be9e6515320533e6907019b12b38 Mon Sep 17 00:00:00 2001 From: Jeffrey Perkel Date: Fri, 11 Feb 2022 09:35:59 -0700 Subject: [PATCH] Add test script --- test_cmdparseR.R | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 test_cmdparseR.R diff --git a/test_cmdparseR.R b/test_cmdparseR.R new file mode 100644 index 0000000..491c3bf --- /dev/null +++ b/test_cmdparseR.R @@ -0,0 +1,27 @@ +library(cmdparseR) + +main <- function() { + init_command_line_parser('test_cmdparseR','Test cmdparseR package','0.1.0') + + args <- list( + c('--config','-c','config','~/myconfigfile.txt',argsType$TypeValue,'Configuration file'), + c('--debug','-d','debug',FALSE,argsType$TypeBool,'Display debug messages'), + c('--keywords','-k','keywords',NA,argsType$TypeMultiVal,'Search keywords'), + c('--daterange','-r','daterange',NA,argsType$TypeRange,'Date range'), + c('--verbose','-v','verbose',0,argsType$TypeCount,'Verbosity level') + ) + reg_argument_list(args) + + pos <- list( + c('outfile',NA,'Output filename'), + c('infiles',NA,'Input filename(s)') + ) + reg_positionals_list(pos) + + args <- commandArgs(trailingOnly = TRUE) + mydata <- parse_command_line(args) + + print(mydata) +} + +main()