substack/node-optimist — pull request #58 by nategood (2012-05-13 16:27:38+00:00)
Title: Support for collecting sensitive arguments (e.g. passwords) via `.protect()`

This adds support for collecting sensitive arguments (like passwords).

When the user defines an argument to protect (and optionally, a prompt), optimist listens on stdin, prevents user input from being written to stdout and fires an event when the user has completed their input. Trivial username/password example:

var argv = require('optimist')
.demand('u')
.protect('p', 'Enter Password:')
.argv;

argv._io.on('input', function(argv) {
console.log('Username: ' + argv.u);
console.log('Secret Password: ' + argv.p);
});

Tests and a new example are included. Event and variable names are up for discussion.