trevorld / r-argparse

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

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

Closed clairemcwhite closed 7 years ago

clairemcwhite commented 7 years ago

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

trevorld commented 7 years ago

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

trevorld commented 5 years ago

@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.