trevorld / r-argparse

command-line optional and positional argument parser
GNU General Public License v2.0
103 stars 11 forks source link

If "type" is "logical" cast according to "as.logical()" logic #39

Closed trevorld closed 2 years ago

trevorld commented 2 years ago
trevorld commented 2 years ago
parser <- ArgumentParser(prog='PROG')
parser$add_argument('-p', type="logical", action="append", help="a list of booleans")
args <- strsplit("-p T -p F -p True -p False -p 1 -p 0 -p badValue", " ")[[1]]
parser$parse_args(args)
[1]  TRUE FALSE  TRUE FALSE    NA    NA    NA
Lain-inrae commented 2 years ago

Thanks that's great!