🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

cli-argparse

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

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.3.7

test/unit/hyphen.js

6

index.js

@@ -6,3 +6,5 @@ var short = '-', long = '--';

function exists(arg, list) {
for(var i = 0;i < list.length;i++){if(~arg.indexOf(list[i])) return true;}
for(var i = 0;i < list.length;i++){
if(arg.indexOf(list[i]) === 0) return true;
}
}

@@ -85,3 +87,3 @@

opt = exists(arg, opts.options);
//console.log('%s %s', arg, flag);
//console.log('arg: %s, flag: %s, opt: %s', arg, flag, opt);
if(opts.strict && (!opt && !flag)) {

@@ -88,0 +90,0 @@ out.unparsed.push(arg);

{
"name": "cli-argparse",
"version": "0.3.6",
"version": "0.3.7",
"description": "Lightweight argument parser",

@@ -10,9 +10,14 @@ "author": "muji <noop@xpm.io>",

},
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"bugs": {
"url": "https://github.com/freeformsystems/cli-argparse/issues"
},
"licenses": [{
"type": "MIT",
"url": "https://github.com/freeformsystems/cli-argparse/blob/master/LICENSE"
}],
"licenses": [
{
"type": "MIT",
"url": "https://github.com/freeformsystems/cli-argparse/blob/master/LICENSE"
}
],
"keywords": [

@@ -33,7 +38,9 @@ "cli",

},
"engine": [ "node >= 0.10.21" ],
"engine": [
"node >= 0.10.21"
],
"scripts": {
"test": "istanbul cover _mocha -- -u bdd --recursive --reporter list -A test/unit/"
},
"config" : {}
"config": {}
}

@@ -27,2 +27,30 @@ var expect = require('chai').expect;

});
it('should allow hyphens in unparsed', function(done) {
var args = [
'-v', '--port=80', 'cmd', '/my-client/my-campaign/my-app'];
var result = parse(args);
//console.dir(result);
expect(result.raw).to.eql(args);
expect(result.flags.v).to.eql(true);
expect(result.options.port).to.be.a('string').that.equals('80');
expect(result.unparsed).to.be.an('array')
.to.eql(['cmd', '/my-client/my-campaign/my-app']);
done();
});
it('should allow hyphens in unparsed (config)', function(done) {
var args = [
'-v', '--port=80', 'cmd', '/my-client/my-campaign/my-app'];
var conf = {
options: [ '-c' ],
flags: [ '-a' ]
}
var result = parse(args, conf);
//console.dir(result);
expect(result.raw).to.eql(args);
expect(result.flags.v).to.eql(true);
expect(result.options.port).to.be.a('string').that.equals('80');
expect(result.unparsed).to.be.an('array')
.to.eql(['cmd', '/my-client/my-campaign/my-app']);
done();
});
})