substack/node-optimist — pull request #95 by coreyjewett (2013-04-30 21:29:37+00:00)
Title: Add .count() "type" for accumulating a count on repeated booleans.

From example/count.js:

#!/usr/bin/env node
var argv = require('optimist')
.count('verbose')
.alias('v', 'verbose')
.argv;

VERBOSE_LEVEL = argv.verbose;

function WARN() { VERBOSE_LEVEL >= 0 && console.log.apply(console, arguments); }
function INFO() { VERBOSE_LEVEL >= 1 && console.log.apply(console, arguments); }
function DEBUG() { VERBOSE_LEVEL >= 2 && console.log.apply(console, arguments); }

WARN("Showing only important stuff");
INFO("Showing semi-mportant stuff too");
DEBUG("Extra chatty mode");