2 var argv = require('optimist')
3 .usage('Count the lines in a file.\nUsage: $0')
6 .alias('f', [ 'file', 'filename' ])
8 "Load a file. It's pretty important."
9 + " Required even. So you'd better specify it."
12 .describe('b', 'Numeric base to display the number of lines in')
14 .describe('x', 'Super-secret optional parameter which is secret')
19 var fs = require('fs');
20 var s = fs.createReadStream(argv.file);
23 s.on('data', function (buf) {
24 lines += buf.toString().match(/\n/g).length;
27 s.on('end', function () {
28 console.log(lines.toString(argv.base));