You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As in #112, I was surprised to find that parsing a flag with a type when the argument is omitted does not error, instead returning null. That issue points to the wiki, which says I should do the validation myself. Fair enough.
Unfortunately, it is impossible to do the validation myself when the flag is specified as multiple, because the output for --flag arg --flag is identical to the output to the output for --flag arg.
Hi, yes the defaultValue for a multiple/lazyMultiple option is the default if the option is not specified at all, i.e.
$ node example.js
{ flag: [ 'default' ] }
This behaviour is correct and by design. But, yes that's a good point in the case that one of the supplied --flag options does not contain a value. In the example you gave, you would expect the output to be `{ flag: [ 'arg', null ] }. Will look into this, thanks.
As in #112, I was surprised to find that parsing a flag with a type when the argument is omitted does not error, instead returning
null
. That issue points to the wiki, which says I should do the validation myself. Fair enough.Unfortunately, it is impossible to do the validation myself when the flag is specified as
multiple
, because the output for--flag arg --flag
is identical to the output to the output for--flag arg
.That is:
invoked with
and with
both give exactly the same output,
So it is not actually possible to check whether the user has passed a flag without specifying its (required) argument.
I was hoping that it would at least put the
default
value in the output array (ornull
, if not specified), which I could check for.The text was updated successfully, but these errors were encountered: