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 0.1.12 to 0.1.13

examples/testformatters.js

8

HISTORY.md

@@ -0,2 +1,9 @@

0.1.13 / 2013-05-08
-------------------
* Added `.npmignore` to reduce package size
0.1.12 / 2013-02-10
-------------------

@@ -7,2 +14,3 @@ * Fixed conflictHandler (#46), @hpaulj

0.1.11 / 2013-02-07
-------------------

@@ -9,0 +17,0 @@ * Multiple bugfixes, @hpaulj

35

lib/action_container.js

@@ -9,3 +9,5 @@ /** internal

var _ = require('underscore');
var format = require('util').format;
var _ = require('underscore');
_.str = require('underscore.string');

@@ -211,6 +213,3 @@

if (! _.isFunction(ActionClass)) {
throw new Error(_.str.sprintf(
'Unknown action "%(action)s".',
{action: ActionClass}
));
throw new Error(format('Unknown action "%s".', ActionClass));
}

@@ -222,6 +221,3 @@ var action = new ActionClass(options);

if (!_.isFunction(typeFunction)) {
throw new Error(_.str.sprintf(
'"%(function)s" is not callable',
{'function': typeFunction}
));
throw new Error(format('"%s" is not callable', typeFunction));
}

@@ -296,3 +292,3 @@

if (titleGroupMap[group.title]) {
throw new Error(_.str.sprintf('Cannot merge actions - two groups are named "%(group.title)s".', group));
throw new Error(format('Cannot merge actions - two groups are named "%s".', group.title));
}

@@ -384,6 +380,6 @@ titleGroupMap[group.title] = group;

if (prefixChars.indexOf(optionString[0]) < 0) {
throw new Error(_.str.sprintf('Invalid option string "%(option)s": must start with a "%(prefix)s".', {
option: optionString,
prefix: prefixChars
}));
throw new Error(format('Invalid option string "%s": must start with a "%s".',
optionString,
prefixChars
));
}

@@ -407,6 +403,5 @@

if (dest.length === 0) {
throw new Error(_.str.sprintf(
'dest= is required for options like "%(option)s"',
{option: optionStrings.join(', ')}
));
throw new Error(
format('dest= is required for options like "%s"', optionStrings.join(', '))
);
}

@@ -469,5 +464,3 @@ dest = dest.replace('-', '_');

action,
_.str.sprintf('Conflicting option string(s): %(conflict)s', {
conflict: conflicts
})
format('Conflicting option string(s): %s', conflicts)
);

@@ -474,0 +467,0 @@ };

2

lib/action.js

@@ -33,4 +33,2 @@ /**

var _ = require('underscore');
_.str = require('underscore.string');

@@ -37,0 +35,0 @@ // Constants

@@ -10,6 +10,7 @@ /** internal

var util = require('util');
var _ = require('underscore');
_.str = require('underscore.string');
var util = require('util');
var format = require('util').format;
var _ = require('underscore');
var Action = require('../action');

@@ -137,8 +138,6 @@

} else {
throw argumentErrorHelper(_.str.sprintf(
'Unknown parser "%(name)s" (choices: [%(choices)s]).',
{
name: parserName,
choices: _.keys(this._nameParserMap).join(', ')
}
throw argumentErrorHelper(format(
'Unknown parser "%s" (choices: [%s]).',
parserName,
_.keys(this._nameParserMap).join(', ')
));

@@ -145,0 +144,0 @@ }

@@ -8,1 +8,8 @@ 'use strict';

module.exports.Const = require('./const.js');
module.exports.ArgumentDefaultsHelpFormatter =
require('./help/added_formatters.js').ArgumentDefaultsHelpFormatter;
module.exports.RawDescriptionHelpFormatter =
require('./help/added_formatters.js').RawDescriptionHelpFormatter;
module.exports.RawTextHelpFormatter =
require('./help/added_formatters.js').RawTextHelpFormatter;

@@ -10,4 +10,5 @@ /**

var util = require('util');
var Path = require('path');
var util = require('util');
var format = require('util').format;
var Path = require('path');

@@ -237,5 +238,3 @@ var _ = require('underscore');

this.error(
_.str.sprintf('Unrecognized arguments: %(args)s.', {
args: argv.join(' ')
})
format('Unrecognized arguments: %s.', argv.join(' '))
);

@@ -386,6 +385,3 @@ }

action,
_.str.sprintf(
'Not allowed with argument "%(argument)s".',
{argument: actionConflict.getName()}
)
format('Not allowed with argument "%s".', actionConflict.getName())
);

@@ -586,3 +582,3 @@ }

if (_.indexOf(seenActions, action) < 0) {
self.error(_.str.sprintf('Argument "%(name)s" is required', {name: action.getName()}));
self.error(format('Argument "%s" is required', action.getName()));
}

@@ -675,3 +671,3 @@ }

default:
message = 'Expected %(count)s argument(s)';
message = 'Expected %s argument(s)';
}

@@ -681,4 +677,4 @@

action,
_.str.sprintf(message, {count: action.nargs}
));
format(message, action.nargs)
);
}

@@ -767,5 +763,5 @@ // return the number of arguments matched

});
this.error(_.str.sprintf(
'Ambiguous option: "%(argument)s" could match %(values)s.',
{argument: argString, values: optionStrings.join(', ')}
this.error(format(
'Ambiguous option: "%s" could match %s.',
argString, optionStrings.join(', ')
));

@@ -844,6 +840,3 @@ // if exactly one action matched, this segmentation is good,

} else {
throw new Error(_.str.sprintf(
'Unexpected option string: %(argument)s.',
{argument: optionString}
));
throw new Error(format('Unexpected option string: %s.', optionString));
}

@@ -974,6 +967,3 @@ // return the collected option tuples

if (!_.isFunction(typeFunction)) {
var message = _.str.sprintf(
'%(callback)s is not callable',
{callback: typeFunction}
);
var message = format('%s is not callable', typeFunction);
throw argumentErrorHelper(action, message);

@@ -997,6 +987,3 @@ }

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

@@ -1032,6 +1019,3 @@ throw argumentErrorHelper(action, msg);

}
var message = _.str.sprintf(
'Invalid choice: %(value)s (choose from [%(choices)s])',
{value: value, choices: choices}
);
var message = format('Invalid choice: %s (choose from [%s])', value, choices);
throw argumentErrorHelper(action, message);

@@ -1183,5 +1167,3 @@ }

}
var msg = _.str.sprintf(
'%(prog)s: error: %(err)s',
{prog: this.prog, err: message}) + $$.EOL;
var msg = format('%s: error: %s', this.prog, message) + $$.EOL;

@@ -1188,0 +1170,0 @@ if (this.debug === true) {

'use strict';
var _ = require('underscore');
_.str = require('underscore.string');
var format = require('util').format;
var ERR_CODE = 'ARGError';

@@ -23,5 +25,3 @@

* action,
* _.str.sprintf('Conflicting option string(s): %(conflict)s', {
* conflict: conflictOptionals.join(', ')
* })
* format('Conflicting option string(s): %s', conflictOptionals.join(', '))
* );

@@ -33,3 +33,2 @@ * }

var argumentName = null;
var format;
var errMessage;

@@ -43,8 +42,9 @@ var err;

}
format = !argumentName ? '%(message)s' : 'argument "%(argumentName)s": %(message)s';
errMessage = _.str.sprintf(format, {
message: message,
argumentName: argumentName
});
if (!argumentName) {
errMessage = message;
} else {
errMessage = format('argument "%s": %s', argumentName, message);
}
err = new TypeError(errMessage);

@@ -51,0 +51,0 @@ err.code = ERR_CODE;

@@ -328,7 +328,7 @@ /**

} else if (!usage && actions.length === 0) {
usage = _.str.sprintf('%(prog)s', {prog: this._prog});
usage = this._prog;
// if optionals and positionals are available, calculate usage
} else if (!usage) {
var prog = _.str.sprintf('%(prog)s', {prog: this._prog});
var prog = this._prog;
var optionals = [];

@@ -481,3 +481,3 @@ var positionals = [];

var parts = [];
actions.forEach(function (action, actionIndex) {

@@ -797,4 +797,4 @@ var part;

var lines = this._splitLines(text, width);
lines.forEach(function (line) {
line = indent + line;
lines = lines.map(function (line) {
return indent + line;
});

@@ -801,0 +801,0 @@ return lines.join($$.EOL);

{
"name" : "argparse",
"description" : "Very powerful CLI arguments parser. Native port of argparse - python's options parsing library",
"version" : "0.1.12",
"version" : "0.1.13",
"keywords" : ["cli", "parser", "argparse", "option", "args"],

@@ -20,8 +20,8 @@ "homepage" : "https://github.com/nodeca/argparse",

"dependencies" : {
"dependencies" : {
"underscore" : "~1.4.3",
"underscore.string" : "~2.3.1"
},
"devDependencies" : { "mocha": "~1.8.1" },
"devDependencies" : { "mocha": "*" },
"engines" : { "node": ">= 0.6.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