felixgirault/essence.js

View on GitHub
bin/essence

Summary

Maintainability
Test Coverage
#!/usr/bin/env node

const program = require('commander');
const pkg = require('../package.json');
const extract = require('..').default;



/**
 *
 */
function extractAction(url) {
    extract(url)
        .then(function(payload) {
            console.log(payload.res.toJson(2));

            if (payload.err.count()) {
                console.log(payload.err.toJson(2));
            }
        })
        .catch(console.error);
}



/**
 *
 */
program.version(pkg.version);

program
    .command('extract [url]')
    .description('extracts information about a web page')
    .action(extractAction);

program.parse(process.argv);