How to use the dashdash.synopsisFromOpt function in dashdash

To help you get started, we’ve selected a few dashdash examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joyent / smartos-live / src / fw / node_modules / cmdln / index.js View on Github external
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');
    }

dashdash

A light, featureful and explicit option parsing library.

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis