trevorld/r-optparse

Number of values an option take is incorrectly calculated when action=='callback' and positional_argument == TRUE

nh3 opened this issue · 2 comments

nh3 commented

r-optparse/R/optparse.R

Lines 630 to 639 in 6f4d9c0

for (ii in seq_along(object@options)) {
option <- object@options[[ii]]
option_strings <- c(option_strings, option@short_flag)
option_strings <- c(option_strings, option@long_flag)
if (option@action == "store") {
n_arguments <- c(n_arguments, 1, 1)
} else {
n_arguments <- c(n_arguments, 0, 0)
}
}

In the above code, line 634 should be

if (!option@action %in% c("store_true", "store_false")) { 

@nh3 Thanks for the bug report! Should be fixed now in the developmental version of optparse.

nh3 commented

Thanks @trevorld for the quick fix. This is very comprehensive.