node-argp
node-argp copied to clipboard
Pass option name as parameter to reviver function
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.