README.md

clinkr

Composable Command Line Interfaces in R

Travis-CI Build Status Coverage Status

The goal of clinkr is to allow argument parsing for R scripts using syntax that follows modern R idioms.

To install the latest development version from github run:

devtools::install_github("travisbyrum/clinkr")

Examples

The following provides an example of a running a command line R script using formatted arguments. You first create a parser object and then define options giving information as to their type, default, and/or flag. In a hypothetical script called test.R you can do this through the following code:

args <- arg_parser() %>% 
  add_option(c('--verbose', '-v'), is_flag = TRUE, help = 'Prints verbose output.') %>%
  add_option('--multiply', type = 'numeric', help = 'Multiply by given number.') %>%
  parse_args()

This follows modern R style with piping to more easily add options and arguments to the parser object. Running the following in the command line ...

Rscript test.R --verbose --multiply 3

the arguments are returned parsed into a named list:

args
#> $multiply
#> [1] 3
#>
#> $verbose
#> [1] TRUE

Inspiration

Todo



travisbyrum/clinkr documentation built on May 31, 2019, 7:46 p.m.