Socket
Socket
Sign inDemoInstall

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.3.0 to 3.0.0

lib/minimist.js

55

index.js
var path = require('path');
var parser = require('./lib/parser');
var wordwrap = require('wordwrap');
var minimist = require('./lib/minimist');
var wordwrap = require('./lib/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 ('default' in opt) {
if (typeof opt.default !== 'undefined') {
self.default(key, opt.default);

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

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

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

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
);
}
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
);
}

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

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

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

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

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

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

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

function rebase (base, dir) {
return path.relative(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;
};
{
"name": "yargs",
"version": "2.3.0",
"version": "3.0.0",
"description": "Light-weight option parsing with an argv hash. No optstrings attached.",

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

],
"dependencies": {
"wordwrap": "0.0.2"
},
"dependencies": {},
"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"

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

@@ -11,6 +11,7 @@ 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=)
> 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) :)
> ~~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).~~
> 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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@@ -334,6 +335,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

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

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

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

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

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

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

@@ -466,17 +457,2 @@ .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)

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

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

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

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

@@ -537,5 +506,2 @@ 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)

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

npm install yargs
or clone this project on github:

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

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

@@ -738,0 +704,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