Skip to content

Conversation

@chrisnovakovic
Copy link

Here's a small change to the invocation of an option's reviver function that informs the function of the option name. This allows reviver functions to fail with error messages written in the same style as the default ones provided by argp, e.g.:

reviver: function(value, option) {
  if (value > 5) {
    this.fail("Option '" + option + "' is not under 5");
  } else {
    return value;
  }
}

Without this option parameter, the reviver function doesn't know whether the user supplied the short or long version of the option, and can't produce that style of error message.

The reviver function is now passed a second parameter to the reviver
function for an option, containing the name of the option for which the
reviver function is being called.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant