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

argparse

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

argparse - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

6

CHANGELOG.md

@@ -0,1 +1,7 @@

1.0.6 / 2016-02-06
------------------
- Maintenance: moved to eslint & updated CS.
1.0.5 / 2016-02-05

@@ -2,0 +8,0 @@ ------------------

24

lib/action_container.js

@@ -112,3 +112,3 @@ /** internal

ActionContainer.prototype._registryGet = function (registryName, value, defaultValue) {
if (3 > arguments.length) {
if (arguments.length < 3) {
defaultValue = null;

@@ -132,3 +132,5 @@ }

for (var property in options) {
this._defaults[property] = options[property];
if ($$.has(options, property)) {
this._defaults[property] = options[property];
}
}

@@ -204,3 +206,3 @@

options.defaultValue = this._defaults[dest];
} else if (typeof this.argumentDefault !== 'undefined') {
} else if (typeof this.argumentDefault !== 'undefined') {
options.defaultValue = this.argumentDefault;

@@ -334,7 +336,5 @@ }

var key = actionHash(action);
if (!!groupMap[key]) {
if (groupMap[key]) {
groupMap[key]._addAction(action);
}
else
{
} else {
this._addAction(action);

@@ -396,3 +396,3 @@ }

if (!dest) {
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] :optionStrings[0];
var optionStringDest = optionStringsLong.length ? optionStringsLong[0] : optionStrings[0];
dest = $$.trimChars(optionStringDest, this.prefixChars);

@@ -427,6 +427,6 @@

var handlerString = this.conflictHandler;
var handlerFuncName = "_handleConflict" + $$.capitalize(handlerString);
var handlerFuncName = '_handleConflict' + $$.capitalize(handlerString);
var func = this[handlerFuncName];
if (typeof func === 'undefined') {
var msg = "invalid conflict resolution value: " + handlerString;
var msg = 'invalid conflict resolution value: ' + handlerString;
throw new Error(msg);

@@ -447,3 +447,3 @@ } else {

if (typeof conflOptional !== 'undefined') {
conflictOptionals.push([optionString, conflOptional]);
conflictOptionals.push([ optionString, conflOptional ]);
}

@@ -459,3 +459,3 @@ });

ActionContainer.prototype._handleConflictError = function (action, conflOptionals) {
var conflicts = conflOptionals.map(function (pair) {return pair[0]; });
var conflicts = conflOptionals.map(function (pair) { return pair[0]; });
conflicts = conflicts.join(', ');

@@ -462,0 +462,0 @@ throw argumentErrorHelper(

@@ -77,10 +77,10 @@ /**

this.dest = options.dest;
this.nargs = options.nargs !== undefined ? options.nargs : null;
this.constant = options.constant !== undefined ? options.constant : null;
this.nargs = typeof options.nargs !== 'undefined' ? options.nargs : null;
this.constant = typeof options.constant !== 'undefined' ? options.constant : null;
this.defaultValue = options.defaultValue;
this.type = options.type !== undefined ? options.type : null;
this.choices = options.choices !== undefined ? options.choices : null;
this.required = options.required !== undefined ? options.required: false;
this.help = options.help !== undefined ? options.help : null;
this.metavar = options.metavar !== undefined ? options.metavar : null;
this.type = typeof options.type !== 'undefined' ? options.type : null;
this.choices = typeof options.choices !== 'undefined' ? options.choices : null;
this.required = typeof options.required !== 'undefined' ? options.required : false;
this.help = typeof options.help !== 'undefined' ? options.help : null;
this.metavar = typeof options.metavar !== 'undefined' ? options.metavar : null;

@@ -90,3 +90,3 @@ if (!(this.optionStrings instanceof Array)) {

}
if (this.required !== undefined && typeof(this.required) !== 'boolean') {
if (typeof this.required !== 'undefined' && typeof this.required !== 'boolean') {
throw new Error('required should be a boolean');

@@ -104,5 +104,5 @@ }

return this.optionStrings.join('/');
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
} else if (this.metavar !== null && this.metavar !== c.SUPPRESS) {
return this.metavar;
} else if (this.dest !== undefined && this.dest !== c.SUPPRESS) {
} else if (typeof this.dest !== 'undefined' && this.dest !== c.SUPPRESS) {
return this.dest;

@@ -109,0 +109,0 @@ }

@@ -27,3 +27,3 @@ /*:nodoc:*

options.nargs = 0;
if (options.constant === undefined) {
if (typeof options.constant === 'undefined') {
throw new Error('constant option is required for appendAction');

@@ -30,0 +30,0 @@ }

@@ -25,7 +25,6 @@ /*:nodoc:*

options.defaultValue = options.defaultValue;
}
else {
} else {
options.defaultValue = c.SUPPRESS;
}
options.dest = (options.dest !== null ? options.dest: c.SUPPRESS);
options.dest = (options.dest !== null ? options.dest : c.SUPPRESS);
options.nargs = 0;

@@ -32,0 +31,0 @@ Action.call(this, options);

@@ -32,3 +32,3 @@ /*:nodoc:*

}
if (this.constant !== undefined && this.nargs !== c.OPTIONAL) {
if (typeof this.constant !== 'undefined' && this.nargs !== c.OPTIONAL) {
throw new Error('nargs must be OPTIONAL to supply const');

@@ -35,0 +35,0 @@ }

@@ -25,3 +25,3 @@ /*:nodoc:*

options.nargs = 0;
if (options.constant === undefined) {
if (typeof options.constant === 'undefined') {
throw new Error('constant option is required for storeAction');

@@ -28,0 +28,0 @@ }

@@ -24,5 +24,5 @@ /*:nodoc:*

options.constant = false;
options.defaultValue = options.defaultValue !== null ? options.defaultValue: true;
options.defaultValue = options.defaultValue !== null ? options.defaultValue : true;
ActionStoreConstant.call(this, options);
};
util.inherits(ActionStoreFalse, ActionStoreConstant);

@@ -23,5 +23,5 @@ /*:nodoc:*

options.constant = true;
options.defaultValue = options.defaultValue !== null ? options.defaultValue: false;
options.defaultValue = options.defaultValue !== null ? options.defaultValue : false;
ActionStoreConstant.call(this, options);
};
util.inherits(ActionStoreTrue, ActionStoreConstant);

@@ -29,3 +29,3 @@ /** internal

**/
var ChoicesPseudoAction = function (name, help) {
function ChoicesPseudoAction(name, help) {
var options = {

@@ -38,3 +38,4 @@ optionStrings: [],

Action.call(this, options);
};
}
util.inherits(ChoicesPseudoAction, Action);

@@ -47,3 +48,3 @@

**/
var ActionSubparsers = module.exports = function ActionSubparsers(options) {
function ActionSubparsers(options) {
options = options || {};

@@ -62,3 +63,4 @@ options.dest = options.dest || c.SUPPRESS;

Action.call(this, options);
};
}
util.inherits(ActionSubparsers, Action);

@@ -137,3 +139,3 @@

// select the parser
if (!!this._nameParserMap[parserName]) {
if (this._nameParserMap[parserName]) {
parser = this._nameParserMap[parserName];

@@ -151,1 +153,3 @@ } else {

};
module.exports = ActionSubparsers;

@@ -25,3 +25,3 @@ /*:nodoc:*

options = options || {};
options.defaultValue = (!!options.defaultValue ? options.defaultValue: c.SUPPRESS);
options.defaultValue = (options.defaultValue ? options.defaultValue : c.SUPPRESS);
options.dest = (options.dest || c.SUPPRESS);

@@ -28,0 +28,0 @@ options.nargs = 0;

@@ -55,3 +55,3 @@ /**

**/
var ArgumentParser = module.exports = function ArgumentParser(options) {
function ArgumentParser(options) {
if (!(this instanceof ArgumentParser)) {

@@ -69,4 +69,4 @@ return new ArgumentParser(options);

options.addHelp = (options.addHelp === undefined || !!options.addHelp);
options.parents = (options.parents || []);
options.addHelp = typeof options.addHelp === 'undefined' || !!options.addHelp;
options.parents = options.parents || [];
// default program name

@@ -83,10 +83,10 @@ options.prog = (options.prog || Path.basename(process.argv[1]));

this.fromfilePrefixChars = options.fromfilePrefixChars || null;
this._positionals = this.addArgumentGroup({title: 'Positional arguments'});
this._optionals = this.addArgumentGroup({title: 'Optional arguments'});
this._positionals = this.addArgumentGroup({ title: 'Positional arguments' });
this._optionals = this.addArgumentGroup({ title: 'Optional arguments' });
this._subparsers = null;
// register types
var FUNCTION_IDENTITY = function (o) {
function FUNCTION_IDENTITY(o) {
return o;
};
}
this.register('type', 'auto', FUNCTION_IDENTITY);

@@ -116,3 +116,3 @@ this.register('type', null, FUNCTION_IDENTITY);

this.addArgument(
[defaultPrefix + 'h', defaultPrefix + defaultPrefix + 'help'],
[ defaultPrefix + 'h', defaultPrefix + defaultPrefix + 'help' ],
{

@@ -125,5 +125,5 @@ action: 'help',

}
if (this.version !== undefined) {
if (typeof this.version !== 'undefined') {
this.addArgument(
[defaultPrefix + 'v', defaultPrefix + defaultPrefix + 'version'],
[ defaultPrefix + 'v', defaultPrefix + defaultPrefix + 'version' ],
{

@@ -141,3 +141,3 @@ action: 'version',

self._addContainerActions(parent);
if (parent._defaults !== undefined) {
if (typeof parent._defaults !== 'undefined') {
for (var defaultKey in parent._defaults) {

@@ -150,4 +150,4 @@ if (parent._defaults.hasOwnProperty(defaultKey)) {

});
}
};
util.inherits(ArgumentParser, ActionContainer);

@@ -164,3 +164,3 @@

ArgumentParser.prototype.addSubparsers = function (options) {
if (!!this._subparsers) {
if (this._subparsers) {
this.error('Cannot have multiple subparser arguments.');

@@ -303,3 +303,3 @@ }

}
return [namespace, args];
return [ namespace, args ];
} catch (e) {

@@ -361,6 +361,5 @@ this.error(e);

}
}
// otherwise, add the arg to the arg strings
// and note the index if it was an option
else {
} else {
// otherwise, add the arg to the arg strings
// and note the index if it was an option
var pattern;

@@ -370,4 +369,3 @@ var optionTuple = self._parseOptional(argString);

pattern = 'A';
}
else {
} else {
optionStringIndices[argStringIndex] = optionTuple;

@@ -394,3 +392,3 @@ pattern = 'O';

seenNonDefaultActions.push(action);
if (!!actionConflicts[actionHash(action)]) {
if (actionConflicts[actionHash(action)]) {
actionConflicts[actionHash(action)].forEach(function (actionConflict) {

@@ -425,3 +423,3 @@ if (seenNonDefaultActions.indexOf(actionConflict) >= 0) {

while (true) {
for (;;) {
if (!action) {

@@ -431,3 +429,3 @@ extras.push(argStrings[startIndex]);

}
if (!!explicitArg) {
if (explicitArg) {
argCount = self._matchArgument(action, 'A');

@@ -440,3 +438,3 @@

if (argCount === 0 && chars.indexOf(optionString[1]) < 0) {
actionTuples.push([action, [], optionString]);
actionTuples.push([ action, [], optionString ]);
optionString = optionString[0] + explicitArg[0];

@@ -449,25 +447,21 @@ var newExplicitArg = explicitArg.slice(1) || null;

explicitArg = newExplicitArg;
}
else {
} else {
throw argumentErrorHelper(action, sprintf('ignored explicit argument %r', explicitArg));
}
}
// if the action expect exactly one argument, we've
// successfully matched the option; exit the loop
else if (argCount === 1) {
} else if (argCount === 1) {
// if the action expect exactly one argument, we've
// successfully matched the option; exit the loop
stop = startIndex + 1;
args = [explicitArg];
actionTuples.push([action, args, optionString]);
args = [ explicitArg ];
actionTuples.push([ action, args, optionString ]);
break;
}
// error if a double-dash option did not use the
// explicit argument
else {
} else {
// error if a double-dash option did not use the
// explicit argument
throw argumentErrorHelper(action, sprintf('ignored explicit argument %r', explicitArg));
}
}
// if there is no explicit argument, try to match the
// optional's string arguments with the following strings
// if successful, exit the loop
else {
} else {
// if there is no explicit argument, try to match the
// optional's string arguments with the following strings
// if successful, exit the loop

@@ -483,3 +477,3 @@ start = startIndex + 1;

actionTuples.push([action, args, optionString]);
actionTuples.push([ action, args, optionString ]);
break;

@@ -515,3 +509,3 @@ }

var argCount = argCounts[i];
if (argCount === undefined) {
if (typeof argCount === 'undefined') {
continue;

@@ -554,4 +548,3 @@ }

nextOptionStringIndex = Math.min(nextOptionStringIndex, position);
}
else {
} else {
nextOptionStringIndex = position;

@@ -569,4 +562,3 @@ }

continue;
}
else {
} else {
startIndex = positionalsEndIndex;

@@ -632,3 +624,3 @@ }

// return the updated namespace and the extra arguments
return [namespace, extras];
return [ namespace, extras ];
};

@@ -638,7 +630,7 @@

// expand arguments referencing files
var _this = this;
var self = this;
var fs = require('fs');
var newArgStrings = [];
argStrings.forEach(function (argString) {
if (_this.fromfilePrefixChars.indexOf(argString[0]) < 0) {
if (self.fromfilePrefixChars.indexOf(argString[0]) < 0) {
// for regular arguments, just add them back into the list

@@ -654,10 +646,10 @@ newArgStrings.push(argString);

content.forEach(function (argLine) {
_this.convertArgLineToArgs(argLine).forEach(function (arg) {
self.convertArgLineToArgs(argLine).forEach(function (arg) {
argstrs.push(arg);
});
argstrs = _this._readArgsFromFiles(argstrs);
argstrs = self._readArgsFromFiles(argstrs);
});
newArgStrings.push.apply(newArgStrings, argstrs);
} catch (error) {
return _this.error(error.message);
return self.error(error.message);
}

@@ -670,3 +662,3 @@ }

ArgumentParser.prototype.convertArgLineToArgs = function (argLine) {
return [argLine];
return [ argLine ];
};

@@ -684,2 +676,3 @@

switch (action.nargs) {
/*eslint-disable no-undefined*/
case undefined:

@@ -716,5 +709,5 @@ case null:

var getLength = function (string) {
function getLength(string) {
return string.length;
};
}

@@ -757,4 +750,4 @@ for (i = actions.length; i > 0; i--) {

// if the option string is present in the parser, return the action
if (!!this._optionStringActions[argString]) {
return [this._optionStringActions[argString], argString, null];
if (this._optionStringActions[argString]) {
return [ this._optionStringActions[argString], argString, null ];
}

@@ -772,5 +765,5 @@

if (!!this._optionStringActions[optionString]) {
if (this._optionStringActions[optionString]) {
action = this._optionStringActions[optionString];
return [action, optionString, argExplicit];
return [ action, optionString, argExplicit ];
}

@@ -813,3 +806,3 @@ }

// in this parser (though it might be a valid option in a subparser)
return [null, argString, null];
return [ null, argString, null ];
};

@@ -841,3 +834,3 @@

action = this._optionStringActions[actionOptionString];
result.push([action, actionOptionString, argExplicit]);
result.push([ action, actionOptionString, argExplicit ]);
}

@@ -856,7 +849,9 @@ }

for (actionOptionString in this._optionStringActions) {
if (!$$.has(this._optionStringActions, actionOptionString)) continue;
action = this._optionStringActions[actionOptionString];
if (actionOptionString === optionPrefixShort) {
result.push([action, actionOptionString, argExplicitShort]);
result.push([ action, actionOptionString, argExplicitShort ]);
} else if (actionOptionString.substr(0, optionPrefix.length) === optionPrefix) {
result.push([action, actionOptionString, argExplicit]);
result.push([ action, actionOptionString, argExplicit ]);
}

@@ -938,5 +933,5 @@ }

value = (action.isOptional()) ? action.constant: action.defaultValue;
value = (action.isOptional()) ? action.constant : action.defaultValue;
if (typeof(value) === 'string') {
if (typeof (value) === 'string') {
value = this._getValue(action, value);

@@ -1014,3 +1009,3 @@ this._checkValue(action, value);

var msg = format('Invalid %s value: %s', name, argString);
if (name === '<function>') {msg += '\n' + e.message; }
if (name === '<function>') { msg += '\n' + e.message; }
throw argumentErrorHelper(action, msg);

@@ -1025,3 +1020,3 @@ }

var choices = action.choices;
if (!!choices) {
if (choices) {
// choise for argument can by array or string

@@ -1039,7 +1034,5 @@ if ((typeof choices === 'string' || Array.isArray(choices)) &&

choices = choices.split('').join(', ');
}
else if (Array.isArray(choices)) {
} else if (Array.isArray(choices)) {
choices = choices.join(', ');
}
else {
} else {
choices = Object.keys(choices).join(', ');

@@ -1106,3 +1099,3 @@ }

var FormatterClass = this.formatterClass;
var formatter = new FormatterClass({prog: this.prog});
var formatter = new FormatterClass({ prog: this.prog });
return formatter;

@@ -1162,7 +1155,6 @@ };

ArgumentParser.prototype.exit = function (status, message) {
if (!!message) {
if (message) {
if (status === 0) {
this._printMessage(message);
}
else {
} else {
this._printMessage(message, process.stderr);

@@ -1192,4 +1184,3 @@ }

message = err.message;
}
else {
} else {
message = err;

@@ -1207,1 +1198,3 @@ }

};
module.exports = ArgumentParser;

@@ -21,5 +21,5 @@ 'use strict';

var ArgumentDefaultsHelpFormatter = function ArgumentDefaultsHelpFormatter(options) {
function ArgumentDefaultsHelpFormatter(options) {
HelpFormatter.call(this, options);
};
}

@@ -32,3 +32,3 @@ util.inherits(ArgumentDefaultsHelpFormatter, HelpFormatter);

if (action.defaultValue !== c.SUPPRESS) {
var defaulting_nargs = [c.OPTIONAL, c.ZERO_OR_MORE];
var defaulting_nargs = [ c.OPTIONAL, c.ZERO_OR_MORE ];
if (action.isOptional() || (defaulting_nargs.indexOf(action.nargs) >= 0)) {

@@ -54,5 +54,5 @@ help += ' (default: %(defaultValue)s)';

var RawDescriptionHelpFormatter = function RawDescriptionHelpFormatter(options) {
function RawDescriptionHelpFormatter(options) {
HelpFormatter.call(this, options);
};
}

@@ -80,5 +80,5 @@ util.inherits(RawDescriptionHelpFormatter, HelpFormatter);

var RawTextHelpFormatter = function RawTextHelpFormatter(options) {
function RawTextHelpFormatter(options) {
RawDescriptionHelpFormatter.call(this, options);
};
}

@@ -85,0 +85,0 @@ util.inherits(RawTextHelpFormatter, RawDescriptionHelpFormatter);

@@ -57,3 +57,3 @@ /**

// format the indented section
if (!!this._parent) {
if (this._parent) {
formatter._indent();

@@ -72,3 +72,3 @@ }

if (!!this._parent) {
if (this._parent) {
formatter._dedent();

@@ -84,3 +84,3 @@ }

heading = '';
if (!!this._heading && this._heading !== c.SUPPRESS) {
if (this._heading && this._heading !== c.SUPPRESS) {
var currentIndent = formatter.currentIndent;

@@ -91,3 +91,3 @@ heading = $$.repeat(' ', currentIndent) + this._heading + ':' + c.EOL;

// join the section-initialize newline, the heading and the help
return formatter._joinParts([c.EOL, heading, itemHelp, c.EOL]);
return formatter._joinParts([ c.EOL, heading, itemHelp, c.EOL ]);
};

@@ -139,3 +139,3 @@

HelpFormatter.prototype._addItem = function (func, args) {
this._currentSection.addItem([func, args]);
this._currentSection.addItem([ func, args ]);
};

@@ -167,3 +167,3 @@

var func = section.formatHelp.bind(section);
this._addItem(func, [this]);
this._addItem(func, [ this ]);
this._currentSection = section;

@@ -204,4 +204,4 @@ };

HelpFormatter.prototype.addText = function (text) {
if (!!text && text !== c.SUPPRESS) {
this._addItem(this._formatText, [text]);
if (text && text !== c.SUPPRESS) {
this._addItem(this._formatText, [ text ]);
}

@@ -227,3 +227,3 @@ };

if (usage !== c.SUPPRESS) {
this._addItem(this._formatUsage, [usage, actions, groups, prefix]);
this._addItem(this._formatUsage, [ usage, actions, groups, prefix ]);
}

@@ -245,3 +245,3 @@ };

// find all invocations
var invocations = [this._formatActionInvocation(action)];
var invocations = [ this._formatActionInvocation(action) ];
var invocationLength = invocations[0].length;

@@ -251,3 +251,3 @@

if (!!action._getSubactions) {
if (action._getSubactions) {
this._indent();

@@ -269,3 +269,3 @@ action._getSubactions().forEach(function (subaction) {

// add the item to the list
this._addItem(this._formatAction, [action]);
this._addItem(this._formatAction, [ action ]);
}

@@ -321,3 +321,3 @@ };

return partStrings.filter(function (part) {
return (!!part && part !== c.SUPPRESS);
return (part && part !== c.SUPPRESS);
}).join('');

@@ -337,3 +337,3 @@ };

if (usage) {
usage = sprintf(usage, {prog: this._prog});
usage = sprintf(usage, { prog: this._prog });

@@ -363,3 +363,3 @@ // if no optionals or positionals are available, usage is just prog

actionUsage = this._formatActionsUsage([].concat(optionals, positionals), groups);
usage = [prog, actionUsage].join(' ');
usage = [ prog, actionUsage ].join(' ');

@@ -387,2 +387,3 @@ // wrap the usage parts if it's too long

// helper for wrapping lines
/*eslint-disable func-style*/ // node 0.10 compat
var _getLines = function (parts, indent, prefix) {

@@ -392,3 +393,3 @@ var lines = [];

var lineLength = !!prefix ? prefix.length - 1: indent.length - 1;
var lineLength = prefix ? prefix.length - 1 : indent.length - 1;

@@ -420,9 +421,9 @@ parts.forEach(function (part) {

lines = [].concat(
_getLines([prog].concat(optionalParts), indent, prefix),
_getLines([ prog ].concat(optionalParts), indent, prefix),
_getLines(positionalParts, indent)
);
} else if (positionalParts) {
lines = _getLines([prog].concat(positionalParts), indent, prefix);
lines = _getLines([ prog ].concat(positionalParts), indent, prefix);
} else {
lines = [prog];
lines = [ prog ];
}

@@ -441,3 +442,3 @@

}
lines = [prog] + lines;
lines = [ prog ] + lines;
}

@@ -474,6 +475,5 @@ // join lines into usage

if (!group.required) {
if (!!inserts[start]) {
if (inserts[start]) {
inserts[start] += ' [';
}
else {
} else {
inserts[start] = '[';

@@ -483,6 +483,5 @@ }

} else {
if (!!inserts[start]) {
if (inserts[start]) {
inserts[start] += ' (';
}
else {
} else {
inserts[start] = '(';

@@ -580,3 +579,3 @@ }

HelpFormatter.prototype._formatText = function (text) {
text = sprintf(text, {prog: this._prog});
text = sprintf(text, { prog: this._prog });
var textWidth = this._width - this._currentIndent;

@@ -620,6 +619,6 @@ var indentIncriment = $$.repeat(' ', this._currentIndent);

// collect the pieces of the action help
parts = [actionHeader];
parts = [ actionHeader ];
// if there was help for the action, add lines of help text
if (!!action.help) {
if (action.help) {
helpText = this._expandHelp(action);

@@ -637,3 +636,3 @@ helpLines = this._splitLines(helpText, helpWidth);

// if there are any sub-actions, add their help as well
if (!!action._getSubactions) {
if (action._getSubactions) {
this._indent();

@@ -654,21 +653,21 @@ action._getSubactions().forEach(function (subaction) {

return metavars[0];
} else {
var parts = [];
var argsDefault;
var argsString;
}
// if the Optional doesn't take a value, format is: -s, --long
if (action.nargs === 0) {
parts = parts.concat(action.optionStrings);
var parts = [];
var argsDefault;
var argsString;
// if the Optional takes a value, format is: -s ARGS, --long ARGS
} else {
argsDefault = action.dest.toUpperCase();
argsString = this._formatArgs(action, argsDefault);
action.optionStrings.forEach(function (optionString) {
parts.push(optionString + ' ' + argsString);
});
}
return parts.join(', ');
// if the Optional doesn't take a value, format is: -s, --long
if (action.nargs === 0) {
parts = parts.concat(action.optionStrings);
// if the Optional takes a value, format is: -s ARGS, --long ARGS
} else {
argsDefault = action.dest.toUpperCase();
argsString = this._formatArgs(action, argsDefault);
action.optionStrings.forEach(function (optionString) {
parts.push(optionString + ' ' + argsString);
});
}
return parts.join(', ');
};

@@ -679,5 +678,5 @@

if (!!action.metavar || action.metavar === '') {
if (action.metavar || action.metavar === '') {
result = action.metavar;
} else if (!!action.choices) {
} else if (action.choices) {
var choices = action.choices;

@@ -689,5 +688,3 @@

choices = choices.join(',');
}
else
{
} else {
choices = Object.keys(choices).join(',');

@@ -703,9 +700,9 @@ }

return result;
} else {
var metavars = [];
for (var i = 0; i < size; i += 1) {
metavars.push(result);
}
return metavars;
}
var metavars = [];
for (var i = 0; i < size; i += 1) {
metavars.push(result);
}
return metavars;
};

@@ -721,2 +718,3 @@ };

switch (action.nargs) {
/*eslint-disable no-undefined*/
case undefined:

@@ -764,10 +762,8 @@ case null:

if (!!params.choices) {
if (params.choices) {
if (typeof params.choices === 'string') {
params.choices = params.choices.split('').join(', ');
}
else if (Array.isArray(params.choices)) {
} else if (Array.isArray(params.choices)) {
params.choices = params.choices.join(', ');
}
else {
} else {
params.choices = Object.keys(params.choices).join(', ');

@@ -782,3 +778,3 @@ }

var lines = [];
var delimiters = [" ", ".", ",", "!", "?"];
var delimiters = [ ' ', '.', ',', '!', '?' ];
var re = new RegExp('[' + delimiters.join('') + '][^' + delimiters.join('') + ']*$');

@@ -785,0 +781,0 @@

@@ -59,3 +59,3 @@ /**

Namespace.prototype.get = function (key, defaultValue) {
return !this[key] ? defaultValue: this[key];
return !this[key] ? defaultValue : this[key];
};

@@ -75,5 +75,4 @@

return value;
} else {
return defaultValue;
}
return defaultValue;
};
{
"name": "argparse",
"description": "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
"version": "1.0.5",
"version": "1.0.6",
"keywords": [

@@ -30,4 +30,7 @@ "cli",

"devDependencies": {
"mocha": "*"
"eslint": "2.0.0-rc.0",
"eslint-plugin-nodeca": "~1.0.3",
"mocha": "*",
"ndoc": "^3.1.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