Skip to content

Commit

Permalink
improve argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
williambelle committed Jan 23, 2017
1 parent dabb09b commit 83a9fd7
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/bin/cli.js
Expand Up @@ -15,14 +15,25 @@ var yargs = require('yargs')
.help('?')
.alias('?', 'help');

var argv = yargs.argv;
var argv = yargs.argv;
var hon = require('../lib/index.js');
var utils = require('honcode-certification-utils');

var hon = require('../lib/index.js');

hon.isHONcodeCertified(argv.url).then(function(isCertified) {
var certifiedUrl = function(isCertified) {
if (isCertified) {
console.log('\n🦄 It\'s safe\n');
} else {
console.log('\n👻 Be careful\n');
}
});
};

if (typeof argv.url !== 'string') {
console.log(argv.url + ' is not a valid url');
process.exit(1);
}

if (utils.isValidUrl(argv.url)) {
hon.isHONcodeCertified(argv.url).then(certifiedUrl);
} else {
console.log(argv.url + ' is not a valid url');
}

0 comments on commit 83a9fd7

Please sign in to comment.