parser icon indicating copy to clipboard operation
parser copied to clipboard

Invoke arg parse function before checking options

Open justinedelson opened this issue 3 years ago • 0 comments

Consider an arg definition like this:

  {
    name: 'something',
    required: true,
    parse: input => input.toUpperCase(),
    options: ['A', 'B'],
  }

Logically an input token of a should be acceptable here because the parse function is provided in order to coerce the lower case value into an upper case value.

This, however, does not work since the token is compared to the options before the parse function is invoked. While in this synthetic case this is easy enough to workaround, in more complex cases it would not be quite so easy.

justinedelson avatar Mar 01 '21 14:03 justinedelson