Skip to content

Commit

Permalink
fixed line ending / using commander.js to resolve args
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigogs committed Feb 2, 2017
1 parent afc0f22 commit e1b53ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
26 changes: 10 additions & 16 deletions bin/easyvpn
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@

'use strict';

function findArgValue(args, names) {
let found = null;
args.forEach((arg, index) => {
if (names.indexOf(arg) > -1) {
found = args[index + 1];
}
});
return found;
}
const program = require('commander');

function hasArg(args, names) {
return !!args.find(arg => (names.indexOf(arg) > -1));
}
program
.version('1.1.3')
.option('-c, --country', 'Country name')
.option('-q, --query', 'Enable country query')
.option('-p, --proxy', 'Proxy url')
.parse(process.argv);

const args = process.argv.slice(2);
const options = {};
options.country = findArgValue(args, ['-c', '--country']);
options.query = hasArg(args, ['-q', '--query']);
options.proxy = findArgValue(args, ['-p', '--proxy']);
if (program.country) options.country = program.country;
if (program.query) options.query = true;
if (program.proxy) options.proxy = program.proxy;

require('../index.js')(options);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "easyvpn",
"version": "1.1.2",
"version": "1.1.3",
"description": "Easy way to get a VPN connection.",
"main": "index.js",
"repository": "https://github.com/rodrigogs/easyvpn.git",
Expand All @@ -21,6 +21,7 @@
},
"dependencies": {
"bluebird": "^3.4.7",
"commander": "^2.9.0",
"csvtojson": "^1.1.3",
"prompt": "^1.0.0",
"request": "^2.79.0",
Expand Down

0 comments on commit e1b53ae

Please sign in to comment.