| var should = require('chai').should(), | ||
| yargs = require('../'); | ||
| describe('parse', function () { | ||
| describe('defaults', function () { | ||
| function checkNoArgs(argv, hasAlias) { | ||
| it('should set defaults if no args', function() { | ||
| var result = argv.parse([ ]); | ||
| result.should.have.property('flag', true); | ||
| if (hasAlias) { | ||
| result.should.have.property('f', true); | ||
| } | ||
| }); | ||
| } | ||
| function checkExtraArg(argv, hasAlias) { | ||
| it('should set defaults if one extra arg', function() { | ||
| var result = argv.parse([ 'extra' ]); | ||
| result.should.have.property('flag', true); | ||
| result.should.have.property('_').and.deep.equal(['extra']); | ||
| if (hasAlias) { | ||
| result.should.have.property('f', true); | ||
| } | ||
| }); | ||
| } | ||
| function checkStringArg(argv, hasAlias) { | ||
| it('should set defaults even if arg looks like a string', function() { | ||
| var result = argv.parse([ '--flag', 'extra' ]); | ||
| result.should.have.property('flag', true); | ||
| result.should.have.property('_').and.deep.equal(['extra']); | ||
| if (hasAlias) { | ||
| result.should.have.property('f', true); | ||
| } | ||
| }); | ||
| } | ||
| describe('for options with aliases', function () { | ||
| var args = yargs().options({ | ||
| flag : { | ||
| alias : 'f', | ||
| default : true | ||
| } | ||
| }); | ||
| checkNoArgs(args, true); | ||
| checkExtraArg(args, true); | ||
| // This test case should fail, because we didn't specify that the | ||
| // option is a boolean | ||
| // checkStringArg(args, true); | ||
| }); | ||
| describe('for typed options without aliases', function () { | ||
| var args = yargs().options({ | ||
| flag : { | ||
| type : 'boolean', | ||
| default : true | ||
| } | ||
| }); | ||
| checkNoArgs(args); | ||
| checkExtraArg(args); | ||
| checkStringArg(args); | ||
| }); | ||
| describe('for typed options with aliases', function () { | ||
| var args = yargs().options({ | ||
| flag : { | ||
| alias : 'f', | ||
| type : 'boolean', | ||
| default : true | ||
| } | ||
| }); | ||
| checkNoArgs(args, true); | ||
| checkExtraArg(args, true); | ||
| checkStringArg(args, true); | ||
| }); | ||
| }); | ||
| }); |
+1
-1
| #!/usr/bin/env node | ||
| var util = require('util'); | ||
| var argv = require('optimist').argv; | ||
| var argv = require('yargs').argv; | ||
@@ -5,0 +5,0 @@ if (argv.s) { |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .boolean(['x','y','z']) | ||
@@ -4,0 +4,0 @@ .argv |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .boolean('v') | ||
@@ -4,0 +4,0 @@ .argv |
+2
-2
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .count('verbose') | ||
@@ -15,2 +15,2 @@ .alias('v', 'verbose') | ||
| INFO("Showing semi-important stuff too"); | ||
| DEBUG("Extra chatty mode"); | ||
| DEBUG("Extra chatty mode"); |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .default({ x : 10, y : 10 }) | ||
@@ -5,0 +5,0 @@ .argv |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .default('x', 10) | ||
@@ -4,0 +4,0 @@ .default('y', 10) |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .demand(2) | ||
| .argv; | ||
| console.dir(argv) |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .usage('Usage: $0 -x [num] -y [num]') | ||
@@ -5,0 +5,0 @@ .demand(['x','y']) |
| #!/usr/bin/env node | ||
| var argv = require('../index') | ||
| var argv = require('yargs') | ||
| .usage('Usage: $0 -x [num] -y [num] -w [msg] -h [msg]') | ||
@@ -26,2 +26,2 @@ .implies({ | ||
| console.log('h: ' +argv.h); | ||
| } | ||
| } |
| #!/usr/bin/env node | ||
| var argv = require('../index') | ||
| var argv = require('yargs') | ||
| .usage('Usage: $0 -x [num] -y [num]') | ||
@@ -10,2 +10,2 @@ .implies('x', 'y') | ||
| console.log(argv.x / argv.y); | ||
| } | ||
| } |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .usage('Count the lines in a file.\nUsage: $0') | ||
@@ -4,0 +4,0 @@ .options({ |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .usage('Count the lines in a file.\nUsage: $0') | ||
@@ -4,0 +4,0 @@ .wrap(80) |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .usage('Count the lines in a file.\nUsage: $0') | ||
@@ -4,0 +4,0 @@ .demand('f') |
| #!/usr/bin/env node | ||
| var argv = require('optimist').argv; | ||
| var argv = require('yargs').argv; | ||
| console.log('(%d,%d)', argv.x, argv.y); | ||
| console.log(argv._); |
+1
-1
| #!/usr/bin/env node | ||
| var argv = require('optimist').argv; | ||
| var argv = require('yargs').argv; | ||
| console.log('(%d,%d)', argv.x, argv.y); |
| #!/usr/bin/env node | ||
| var argv = require('optimist') | ||
| var argv = require('yargs') | ||
| .string('x', 'y') | ||
@@ -4,0 +4,0 @@ .argv |
@@ -1,4 +0,4 @@ | ||
| var optimist = require('./../index'); | ||
| var yargs = require('yargs'); | ||
| var argv = optimist.usage('This is my awesome program', { | ||
| var argv = yargs.usage('This is my awesome program', { | ||
| 'about': { | ||
@@ -16,5 +16,5 @@ description: 'Provide some details about the author of this program', | ||
| optimist.showHelp(); | ||
| yargs.showHelp(); | ||
| console.log('\n\nInspecting options'); | ||
| console.dir(argv); | ||
| console.dir(argv); |
+1
-2
| #!/usr/bin/env node | ||
| var argv = require('optimist').argv; | ||
| var argv = require('yargs').argv; | ||
@@ -10,2 +10,1 @@ if (argv.rif - 5 * argv.xup > 7.138) { | ||
| } | ||
+9
-0
@@ -53,2 +53,11 @@ var path = require('path'); | ||
| Object.keys(defaults || {}).forEach(function (key) { | ||
| if (/-/.test(key) && !opts.alias[key]) { | ||
| aliases[key] = (aliases[key] || []).concat(toCamelCase(key)); | ||
| } | ||
| (aliases[key] || []).forEach(function (alias) { | ||
| defaults[alias] = defaults[key]; | ||
| }); | ||
| }); | ||
| var argv = { _ : [] }; | ||
@@ -55,0 +64,0 @@ Object.keys(flags.bools).forEach(function (key) { |
+1
-1
| { | ||
| "name": "yargs", | ||
| "version": "1.2.2", | ||
| "version": "1.2.3", | ||
| "description": "Light-weight option parsing with an argv hash. No optstrings attached.", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
+4
-2
@@ -424,4 +424,4 @@ yargs | ||
| .usage(message) | ||
| --------------- | ||
| .usage(message, opts) | ||
| --------------------- | ||
@@ -432,2 +432,4 @@ Set a usage message to show which commands to use. Inside `message`, the string | ||
| `opts` is optional and acts like calling `.options(opts)`. | ||
| .example(cmd, desc) | ||
@@ -434,0 +436,0 @@ ------------------- |
@@ -37,2 +37,37 @@ var should = require('chai').should(), | ||
| it('should provide defaults of options with dashes as camelCase properties', function() { | ||
| var result = yargs() | ||
| .option('some-option', { | ||
| describe : 'some option', | ||
| default : 'asdf' | ||
| }) | ||
| .parse([ ]); | ||
| result.should.have.property('someOption', 'asdf'); | ||
| }); | ||
| it('should provide aliases of options with dashes as camelCase properties', function() { | ||
| var result = yargs() | ||
| .option('some-option', { | ||
| alias : 'o', | ||
| describe : 'some option', | ||
| default : 'asdf' | ||
| }) | ||
| .parse([ ]); | ||
| result.should.have.property('o', 'asdf'); | ||
| }); | ||
| it('should provide aliases of options with dashes as camelCase properties', function() { | ||
| var result = yargs() | ||
| .option('o', { | ||
| alias : 'some-option', | ||
| describe : 'some option', | ||
| default : 'asdf' | ||
| }) | ||
| .parse([ ]); | ||
| result.should.have.property('someOption', 'asdf'); | ||
| }); | ||
| it('should provide aliases with dashes as camelCase properties', function() { | ||
@@ -39,0 +74,0 @@ var result = yargs() |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
86010
5.11%39
2.63%1813
6.58%616
0.33%