this._options.forEach(function (option) { if (option._hidden) return; var message = []; if (option._short.length) message.push(option._short.map(function (_short) { return ' \0bold(\0green(-' + _short + '\0)\0)'; }).join('')); if (option._long.length) message.push(option._long.map(function (_long) { return ' \0bold(\0green(--' + _long + '\0)\0)'; }).join('')); if (option._action.length > 2) message.push( ' ' + util.range(option._action.length - 2) .map(function () { return '\0bold(\0green(' + util.upper( option.getName() ) + '\0)\0)'; }).join(' ') ); if (option._help) message.push(': ' + option._help + ''); if (option._choices) { var choices = option._choices; if (!util.isArrayLike(choices)) choices = util.keys(choices); message.push(' \0bold(\0blue((' + choices.join(', ') + ')\0)\0)'); } if (option._halt) message.push(' \0bold(\0blue((final option)\0)\0)'); self.print(message.join('')); });
exports.Parser.prototype.printOption = function (options, option, depth, parent) { var self = this; depth = depth || 0; var indent = util.mul(' ', depth); if (option._hidden) return; if (option._group !== parent) return; if (option instanceof exports.Group) { self.print(indent + ' \0yellow(' + option._name + ':\0)'); var parent = option; option._options.forEach(function (option) { return self.printOption(options, option, depth + 1, parent); }); return; } var message = []; if (option._short.length) message.push(option._short.map(function (_short) { return ' \0bold(\0green(-' + _short + '\0)\0)'; }).join('')); if (option._long.length) message.push(option._long.map(function (_long) { return ' \0bold(\0green(--' + _long + '\0)\0)'; }).join('')); if (option._action && option._action.length > 2) message.push( ' ' + util.range(option._action.length - 2) .map(function () { return '\0bold(\0green(' + util.upper( option.getDisplayName() ) + '\0)\0)'; }).join(' ') ); if (option._help) message.push(': ' + option._help + ''); if (option._choices) { var choices = option._choices; if (!util.isArrayLike(choices)) choices = util.keys(choices); message.push(' \0bold(\0blue((' + choices.join(', ') + ')\0)\0)'); } if (option._halt) message.push(' \0bold(\0blue((final option)\0)\0)'); self.print(indent + message.join('')); };
exports.testRange2 = function () { assert.eq([1, 2, 3], util.range(1, 4)); };
exports.testRange1 = function () { assert.eq([0, 1, 2], util.range(3)); };
exports.testRange3 = function () { assert.eq([2, 4, 6], util.range(2, 8, 2)); };