trevorld/r-argparse

Use of the argparse 'required' argument causes default arguments to be required

clairemcwhite opened this issue · 2 comments

This happens whether you set required as FALSE or TRUE.

Works fine

parser <- ArgumentParser()
parser$add_argument("-o", "--output_filename", action="store",
                        dest="output_filename", help="Output filename for resulting plot", default="outfile.txt")
args <- parser$parse_args()
print(args$output_filename)

[1] "outfile.txt"

Gives error

parser <- ArgumentParser()
parser$add_argument("-o", "--output_filename", action="store", required=FALSE,
                        dest="output_filename", help="Output filename for resulting plot", default="outfile.txt")
args <- parser$parse_args()
print(args$output_filename)

error: argument -o/--output_filename is required

Thanks for the bug report! Should be fixed now in the developmental version.

@chinnarii Your comment has been removed because not only is it off-topic of this particular issue it is related to a completely different programming language (python) and is hence off-topic to this R package.