Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

yargs

Package Overview
Dependencies
Maintainers
2
Versions
250
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yargs - npm Package Compare versions

Comparing version 2.1.1 to 2.3.0

lib/parser.js

55

index.js
var path = require('path');
var minimist = require('./lib/minimist');
var wordwrap = require('./lib/wordwrap');
var parser = require('./lib/parser');
var wordwrap = require('wordwrap');

@@ -192,3 +192,3 @@ /* Hack an instance of Argv with process.argv into Argv

}else{
throw new Error(msg);
throw new Error(msg);
}

@@ -237,3 +237,3 @@ }

if (typeof opt.default !== 'undefined') {
if ('default' in opt) {
self.default(key, opt.default);

@@ -305,4 +305,4 @@ }

if (typeof enabled === 'string') {
message = enabled;
enabled = true;
message = enabled;
}

@@ -446,9 +446,13 @@ else if (typeof enabled === 'undefined') {

body = desc + (dlen + extra.length > wrap - 2
? '\n'
+ new Array(wrap - extra.length + 1).join(' ')
+ extra
: new Array(wrap - extra.length - dlen + 1).join(' ')
+ extra
);
if (extra.length > wrap) {
body = desc + '\n' + wordwrap(switchlen + 4, wrap)(extra)
} else {
body = desc + (dlen + extra.length > wrap - 2
? '\n'
+ new Array(wrap - extra.length + 1).join(' ')
+ extra
: new Array(wrap - extra.length - dlen + 1).join(' ')
+ extra
);
}
}

@@ -464,3 +468,13 @@

Object.defineProperty(self, 'argv', {
get : function () { return parseArgs(processArgs) },
get : function () {
var args = null;
try {
args = parseArgs(processArgs);
} catch (err) {
fail(err.message);
}
return args;
},
enumerable : true

@@ -470,3 +484,3 @@ });

function parseArgs (args) {
var parsed = minimist(args, options),
var parsed = parser(args, options),
argv = parsed.argv,

@@ -510,3 +524,3 @@ aliases = parsed.aliases;

// minimist sets --foo value to true / --no-foo to false
// parser sets --foo value to true / --no-foo to false
if (value === true || value === false) {

@@ -653,12 +667,3 @@ missingRequiredArgs.push(key);

function rebase (base, dir) {
var ds = path.normalize(dir).split('/').slice(1);
var bs = path.normalize(base).split('/').slice(1);
for (var i = 0; ds[i] && ds[i] == bs[i]; i++);
ds.splice(0, i); bs.splice(0, i);
var p = path.normalize(
bs.map(function () { return '..' }).concat(ds).join('/')
).replace(/\/$/,'').replace(/^$/, '.');
return p.match(/^[.\/]/) ? p : './' + p;
return path.relative(base, dir);
};
{
"name": "yargs",
"version": "2.1.1",
"version": "2.3.0",
"description": "Light-weight option parsing with an argv hash. No optstrings attached.",

@@ -11,8 +11,12 @@ "main": "./index.js",

],
"dependencies": {},
"dependencies": {
"wordwrap": "0.0.2"
},
"devDependencies": {
"blanket": "^1.1.6",
"chai": "^1.10.0",
"coveralls": "^2.11.2",
"hashish": "0.0.4",
"mocha": "^2.1.0",
"mocha-lcov-reporter": "0.0.1",
"mocoverage": "^1.0.0"

@@ -19,0 +23,0 @@ },

@@ -11,7 +11,6 @@ yargs

[![NPM version](https://badge.fury.io/js/yargs.png)](http://badge.fury.io/js/yargs)
[![Coverage Status](https://coveralls.io/repos/chevex/yargs/badge.svg?branch=)](https://coveralls.io/r/chevex/yargs?branch=)
> ~~NOTE: Yargs is a fork of [optimist](https://github.com/substack/node-optimist) by [substack (James Halliday)](https://github.com/substack). It is obvious that substack is stretched pretty thin maintaining over 300 modules on npm at the time of this writing. So rather than complain in the project issue tracker I thought I'd just pick up the torch and maintain a proper fork. Currently the project is totally backward compatible with optimist but this may change in the future (if it does I will update this notice to inform you of this). For now though, enjoy optimist with about 5 months worth of fixes and updates rolled in, most of them pulled from optimist's own [stale pull requests](https://github.com/substack/node-optimist/pulls).~~
> Yargs is the official successor to optimist. Please feel free to submit issues and pull requests. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/chevex/yargs/issues) :)
> UPDATE: Yargs is now the official successor to optimist. Please feel free to submit issues and pull requests. While I personally don't have the time to pore over all the issues and fix all of them on a regular basis, I'm more than happy to look over pull requests, test them, and merge them in. If you'd like to contribute and don't know where to start, have a look at [the issue list](https://github.com/chevex/yargs/issues) :)
examples

@@ -41,3 +40,3 @@ ========

Plunder more riffiwobbles!
$ ./xup.js --rif 12 --xup 8.1

@@ -50,3 +49,3 @@ Drop the xupptumblers!

-------------------------------------------------
short.js:

@@ -87,3 +86,3 @@

The parrot says: squawk
$ ./bool.js -sp

@@ -97,3 +96,3 @@ The parrot says: squawk!

-------------------------------------------------
nonopt.js:

@@ -113,3 +112,3 @@

[ 'rum' ]
$ ./nonopt.js "me hearties" -x 0.54 yo -y 1.12 ho

@@ -176,6 +175,6 @@ (0.54,1.12)

***
$ ./divide.js -x 55 -y 11
5
$ node ./divide.js -x 4.91 -z 2.51

@@ -268,4 +267,4 @@ Usage: node ./divide.js -x [num] -y [num]

[ 'me hearties', 'yo', 'ho' ]
boolean_double.js

@@ -335,6 +334,6 @@

$ node line_count.js --file line_count.js
$ node line_count.js --file line_count.js
20
$ node line_count.js -f line_count.js
$ node line_count.js -f line_count.js
20

@@ -415,2 +414,9 @@

.implies(x, y)
--------------
Given the key `x` is set, it is required that the key `y` is set.
implies can also accept an object specifying multiple implications.
.describe(key, desc)

@@ -428,3 +434,3 @@ --------------------

Instead of chaining together `.alias().demand().default()`, you can specify
Instead of chaining together `.alias().demand().default().describe().string()`, you can specify
keys in `opt` for each of the chainable methods.

@@ -438,3 +444,6 @@

alias : 'file',
default : '/etc/passwd',
demand: true,
default: '/etc/passwd',
describe: 'x marks the spot',
type: 'string'
})

@@ -457,2 +466,17 @@ .argv

````javascript
var argv = require('yargs')
.options({
'f': {
alias: 'file',
demand: true,
default: '/etc/passwd',
describe: 'x marks the spot',
type: 'string'
}
})
.argv
;
````
.usage(message, opts)

@@ -485,2 +509,9 @@ ---------------------

.fail(fn)
---------
Method to execute when a failure occurs, rather then printing the failure message.
`fn` is called with the failure message that would have been printed.
.boolean(key)

@@ -492,4 +523,4 @@ -------------

If `key` never shows up as a flag in `process.arguments`, `argv[key]` will be
`false`.
`key` will default to `false`, unless an `default(key, undefined)` is
explicitly set.

@@ -506,2 +537,5 @@ If `key` is an Array, interpret all the elements as booleans.

`.string('_')` will result in non-hyphenated arguments being interpreted as strings,
regardless of whether they resemble numbers.
.config(key)

@@ -690,3 +724,3 @@ ------------

npm install yargs
or clone this project on github:

@@ -698,6 +732,6 @@

just do:
expresso
inspired By
inspired by
===========

@@ -704,0 +738,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc