Sha256: c2f63394021c7283451d52169a7b5143f869400fe992b055cea13d5d9b5bec35

Contents?: true

Size: 635 Bytes

Versions: 356

Compression:

Stored size: 635 Bytes

Contents

#!/usr/bin/env node
var argv = require('optimist')
    .usage('Count the lines in a file.\nUsage: $0')
    .options({
        file : {
            demand : true,
            alias : 'f',
            description : 'Load a file'
        },
        base : {
            alias : 'b',
            description : 'Numeric base to use for output',
            default : 10,
        },
    })
    .argv
;

var fs = require('fs');
var s = fs.createReadStream(argv.file);

var lines = 0;
s.on('data', function (buf) {
    lines += buf.toString().match(/\n/g).length;
});

s.on('end', function () {
    console.log(lines.toString(argv.base));
});

Version data entries

356 entries across 211 versions & 18 rubygems

Version Path
ela-4.0.0 node_modules/optimist/example/line_count_options.js
ela-3.4.3 node_modules/optimist/example/line_count_options.js
ela-3.4.2 node_modules/optimist/example/line_count_options.js
ela-3.4.0 node_modules/optimist/example/line_count_options.js
ela-3.3.1 node_modules/optimist/example/line_count_options.js
ela-3.3.0 node_modules/optimist/example/line_count_options.js
ela-3.2.0 node_modules/optimist/example/line_count_options.js
ela-3.1.1 node_modules/optimist/example/line_count_options.js
ela-3.1.0 node_modules/optimist/example/line_count_options.js
ela-3.0.0 node_modules/optimist/example/line_count_options.js
ela-2.0.0 node_modules/optimist/example/line_count_options.js
ela-1.1.0 node_modules/optimist/example/line_count_options.js
lanes-0.8.0 node_modules/optimist/example/line_count_options.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/bower-config/node_modules/optimist/example/line_count_options.js
trusty-festivity-extension-2.6.3 node_modules/bower/node_modules/handlebars/node_modules/optimist/example/line_count_options.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/handlebars/node_modules/optimist/example/line_count_options.js
trusty-festivity-extension-2.6.2 node_modules/bower/node_modules/bower-config/node_modules/optimist/example/line_count_options.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/handlebars/node_modules/optimist/example/line_count_options.js
trusty-festivity-extension-2.6.1 node_modules/bower/node_modules/bower-config/node_modules/optimist/example/line_count_options.js
trusty-festivity-extension-2.6 node_modules/bower/node_modules/handlebars/node_modules/optimist/example/line_count_options.js