Thank you for the very nice and useful package!
I have been using the package since version 0.4, also for parsing negative numeric arguments, but since version 0.6, negative numeric arguments cannot be passed through the command line.
For example, save the following script as negnum.R:
p <- argparser::arg_parser('negative numeric issue')
p <- argparser::add_argument(p, '--numarg',
help = 'number help',
default = -0.9)
parsed <- argparser::parse_args(p)
print(parsed[['numarg']])
Then, try:
Rscript negnum.R --numarg '-0.7'
You get the following error:
Error in (function (object, class, nargs) :
Invalid argument value: expecting numeric but got: (-0.7).
Calls: <Anonymous> -> mapply -> <Anonymous>
Execution halted
I believe that the issue arises from the restrictive regular expressions in argparser.R, e.g.,
"^(([0-9]+)|([0-9]*\\.[0-9]+)|-?Inf)$"
I think the regular expression should at least include an optional negative sign and maybe also optional spaces before the sign and/or number. What do you think?
Thank you for this bug report, and I apologize for my insufficient testing.
I have just fixed this bug in commit 04b1783.
I am not implementing the optional space between the number and the sign, because the command line arguments are tokenized before being passed into R, and any whitespace is consider a delimiter. I am reluctant to implement an exception/work-around to this simple and understandable parsing mechanism.
CRAN is currently not allowing any package updates due to the holidays. Pending additional testing, I will submit the next release to CRAN by the end of January. In the meanwhile, please install commit 04b1783 using `devtools`. Please be sure to follow the instructions in the `README`, because you will need to build the documentation. I strongly prefer not to commit any generated files into the git repo.