You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP →

cli-argparse

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cli-argparse - npm Package Compare versions

Comparing version

to
0.1.3

var short = '-', long = '--';
var sre = /^-[^-]+/, lre = /^--[^-]+/, negate = /^--no-/;
var sre = /^-[^-]+/, lre = /^--[^-]+/, negate = /--no-/;
var camelcase = require('cli-util').camelcase;

@@ -17,3 +17,4 @@

keys = z.split(/\s+/);
if(keys.indexOf(key) > -1) return {key: alias[z], aliased: true, negated: /--no-/.test(z)};
if(~keys.indexOf(key)) return {key: alias[z],
aliased: true, negated: negate.test(z)};
}

@@ -25,11 +26,10 @@ return {key: key, aliased: false};

var result = alias(arg, opts), keys, skip = false, i = 0, key, v = true;
if(result.aliased) output.flags[result.key] = true;
if(result.aliased) output.flags[result.key] = v;
arg = arg.replace(/^-/, ''); keys = arg.split('');
for(;i < keys.length;i++, key = keys[i]) {
key = keys[i];
if(i == keys.length - 1 && opts.options.indexOf(short + key) > -1) {
if(i == keys.length - 1 && ~opts.options.indexOf(short + key)) {
return options(short + key, output, next, opts);
}
result = alias(short + key, opts);
// short option flag has an alias component that negates (--no-)
if(result.negated) v = false;

@@ -43,9 +43,9 @@ output.flags[result.aliased ? result.key : key] = v;

var equals = arg.indexOf('='), value, result = false, negated, key;
var flag = (!next && equals == -1)
|| (next && next.indexOf(short) == 0 && equals == -1);
if(equals > -1) {
var flag = (!next && !~equals)
|| (next && next.indexOf(short) == 0 && !~equals);
if(~equals) {
value = arg.slice(equals + 1); arg = arg.slice(0, equals);
}
if(opts.flags.indexOf(arg) > -1) flag = true;
if(next && !flag && equals == -1) {
if(~opts.flags.indexOf(arg)) flag = true;
if(next && !flag && !~equals) {
value = next; result = true;

@@ -82,3 +82,3 @@ }

opts.options.forEach(function(o){
if(arg.indexOf(o) > -1) larg = true;
if(~arg.indexOf(o)) larg = true;
});

@@ -85,0 +85,0 @@ if(arg == short) {

{
"name": "cli-argparse",
"version": "0.1.2",
"version": "0.1.3",
"description": "Lightweight argument parser",

@@ -5,0 +5,0 @@ "author": "muji <noop@xpm.io>",