Optional array argument is always defined
garysassano opened this issue · comments
Gary Sassano commented
I've noticed a difference between an optional standard argument and an array argument.
program
.command("test")
.argument("[entrypoint]")
In this case entrypoint = undefined
if the user doesn't specify any argument.
program
.command("test")
.argument("[entrypoint...]")
In this case entrypoint = []
if the user doesn't specify any argument, whereas I expected it to be undefined
.
John Gee commented
Yes, the variadic optional argument has behaved like that since it was added.
(It would also have been reasonable to return undefined for no arguments, as you expected.)