Closed capnrefsmmat closed 6 years ago
I agree that the error message isn't very helpful.
All arguments to ArgumentParser
are supposed to be keyword arguments, so pasting afterwards or before the prog=
argument shouldn't matter since user should always supply each argument name in that function. Just like in python you need to use add_argument
if you want to add a (positional) argument:
library("argparse")
parser <- ArgumentParser(description="This program does this cool thing")
parser$add_argument("command_name")
args <- parser$parse_args()
With the following reasonable-looking argparse code:
we get the message
because
parser$python_code
iswhich is a
SyntaxError
, because positional arguments cannot come after keyword arguments.First, it'd be helpful to present
SyntaxError
s to the user instead of the JSON error that results from trying to parse them. Second, perhaps it's incorrect for argparse to paste the user-provided arguments after theprog=
argument it provides?Thanks!