Closed dariober closed 2 years ago
After 2cf5429 the message (with default R error handler) is now:
usage: test.R [-h] [--param PARAM]
test.R: error: argument --param: invalid int value: 'foo'
Execution halted
To get rid of the trailing "Execution halted" you'll need to manually set your own error handler e.g.
#!/usr/bin/env Rscript
library(argparse)
if (!interactive())
options(error=function(e) quit('no', status = 1, runLast = FALSE))
parser <- ArgumentParser()
parser$add_argument('--param', type= 'integer')
xargs <- parser$parse_args()
will get you to
usage: test.R [-h] [--param PARAM]
test.R: error: argument --param: invalid int value: 'foo'
It's no biggie at all but if easy to fix it would be nice... Passing an invalid argument gives a meaningful error plus some extra error from R that clutters the message. For example:
Run with an invalid argument:
It would be slightly preferable if the message was just: