match_args: Match command arguments against a list of parser arguments

Description Usage Arguments Examples

Description

This function can be used to interact with the low-level functionality of the cmdline.arguments package. The match_args function takes a vector of commandline argmuments, parser arguments and other descriptors and returns a named list of extracted value from cmdArgs. The interface is however not user-friendly.

Usage

1
2
3
4
5
6
7
8
match_args(
  cmdArgs = commandArgs(TRUE),
  parserArgs,
  parserArgsRequired,
  helpArg,
  sarg,
  larg
)

Arguments

cmdArgs

vector of commandline arguments. Defaults to commandArgs(TRUE)

parserArgs

arguments to be searched for

parserArgsRequired

logical vector indicaing whether an argument is strictly required

helpArg

the argument used if one seeks help with the package

sarg

short argument indicator (one letter arguments). No default

larg

long argument indicator (one or more letter).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
cmdArgs <- c('--go', 'abc', 'efd', '-g', 'my world', '--garage', 'no', '-f', '-v')
parserArgs <- list(c('-g', '--garage'), '--go', '-f', '-v')
parserArgsRequired <- rep(TRUE, 4)
helpArg <- '--help'
sarg <- '-'
larg <- '--'
match_args(cmdArgs,
           parserArgs,
           parserArgsRequired,
           helpArg,
           sarg,
           larg)

Bijaelo/cmdline.arguments documentation built on June 12, 2021, 1:42 p.m.