trevorld / r-argparse

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

Way to handle space-containing arguments #33

Closed agilly closed 3 years ago

agilly commented 3 years ago

In the following example:

#!/usr/bin/env Rscript
suppressPackageStartupMessages(library("argparse"))
parser <- ArgumentParser()
parser$add_argument("-d", "--covar-id-col",
        help="ID column in the covariate file.")

I would like to pass arguments containing spaces, as in ./myscript.R -d "my column". Neither single quotes, double quotes or prefixing quoted expression with $ works. Can you share a way to pass space-containing values to arguments?

The only thing I could see would be to give the length Inf to the argument but that would require users to add -- afterwards, wouldn't it?

Any help appreciated & thanks for a great library!

agilly commented 3 years ago

Apologies, I was debugging the wrong argument. Double quotes work as expected.