Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
OptionError.prototype.cmdlnErrHelpFromErr = function optionErrHelpFromErr(err) {
if (!err || !err._cmdlnInst) {
return '';
}
var errHelp = '';
var options = (err._cmdlnHandler || err._cmdlnInst).options;
if (options) {
var lines = [];
var line = 'usage: ' + nameFromErr(err);
for (var i = 0; i < options.length; i++) {
var synopsis = dashdash.synopsisFromOpt(options[i]);
if (!synopsis) {
continue;
} else if (line.length === 0) {
line += ' ' + synopsis;
} else if (line.length + synopsis.length + 1 > 80) {
lines.push(line);
line = ' ' + synopsis;
} else {
line += ' ' + synopsis;
}
}
lines.push(line + ' ...'); // The "..." for the args.
errHelp = lines.join('\n');
}