Socket
Socket
Sign inDemoInstall

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.0 to 0.1.1

7

HISTORY.md

@@ -0,1 +1,8 @@

0.1.1 / 2012-05-23
------------------
* Fixed line wrapping in help formatter
* Added better error reporting on invalid arguments
0.1.0 / 2012-05-16

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

23

lib/action_container.js

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

/*:nodoc:*
/** internal
* class ActionContainer

@@ -33,3 +33,3 @@ *

/*:nodoc:*
/**
* new ActionContainer(options)

@@ -95,3 +95,3 @@ *

/*:nodoc:*
/**
* ActionContainer#register(registryName, value, object) -> Void

@@ -118,3 +118,3 @@ * - registryName (String) : object type action|type

/*:nodoc:*
/**
* ActionContainer#setDefaults(options) -> Void

@@ -140,3 +140,3 @@ * - options (object):hash of options see [[Action.new]]

/*:nodoc:*
/**
* ActionContainer#getDefault(dest) -> Mixed

@@ -160,3 +160,3 @@ * - dest (string): action destination

/*:nodoc:*
/**
* ActionContainer#addArgument(args, options) -> Object

@@ -171,5 +171,12 @@ * - args (Array): array of argument keys

ActionContainer.prototype.addArgument = function (args, options) {
args = args || [];
args = args;
options = options || {};
if (!_.isArray(args)) {
throw new TypeError('addArgument first argument should be an array');
}
if (!_.isObject(options) || _.isArray(options)) {
throw new TypeError('addArgument second argument should be a hash');
}
// if no positional args are supplied or only one is supplied and

@@ -220,3 +227,3 @@ // it doesn't look like an option string, parse a positional argument

/*:nodoc:*
/**
* ActionContainer#addArgumentGroup(options) -> ActionGroup

@@ -223,0 +230,0 @@ * - options (Object): hash of options see [[ActionGroup.new]]

@@ -139,3 +139,9 @@ /**

* Call the action. Should be implemented in inherited classes
* See example [store action](http://github.com/nodeca/argparse/blob/master/lib/action/store.js#L48)
*
* ##### Example
*
* ActionCount.prototype.call = function (parser, namespace, values, optionString) {
* namespace.set(this.dest, (namespace[this.dest] || 0) + 1);
* };
*
**/

@@ -142,0 +148,0 @@ Action.prototype.call = function (parser, namespace, values, optionString) {

@@ -5,2 +5,3 @@ /**

* Object for parsing command line strings into js objects.
*
* Inherited from [[ActionContainer]]

@@ -7,0 +8,0 @@ **/

@@ -17,3 +17,14 @@ 'use strict';

*
* See also [usage example](https://github.com/nodeca/argparse/blob/master/lib/action_container.js#L401)
* #####Example
*
* var argumentErrorHelper = require('./argument/error');
* if (conflictOptionals.length > 0) {
* throw argumentErrorHelper(
* action,
* _.str.sprintf('Conflicting option string(s): %(conflict)s', {
* conflict: conflictOptionals.join(', ')
* })
* );
* }
*
**/

@@ -20,0 +31,0 @@ var argumentError = module.exports = function (argument, message) {

@@ -117,3 +117,3 @@ /**

this._whitespaceMatcher = new RegExp('\\s+');
this._whitespaceMatcher = new RegExp('\\s+', 'g');
this._longBreakMatcher = new RegExp($$.EOL + $$.EOL + $$.EOL + '+');

@@ -151,3 +151,9 @@ };

*
* [1]:http://github.com/nodeca/argparse/blob/master/lib/argument_parser.js#L953
* ##### Example
*
* formatter.startSection(actionGroup.title);
* formatter.addText(actionGroup.description);
* formatter.addArguments(actionGroup._groupActions);
* formatter.endSection();
*
**/

@@ -167,5 +173,8 @@ HelpFormatter.prototype.startSection = function (heading) {

*
* See alse [code example][1]
* ##### Example
*
* [1]:http://github.com/nodeca/argparse/blob/master/lib/argument_parser.js#L953
* formatter.startSection(actionGroup.title);
* formatter.addText(actionGroup.description);
* formatter.addArguments(actionGroup._groupActions);
* formatter.endSection();
**/

@@ -183,5 +192,9 @@ HelpFormatter.prototype.endSection = function () {

*
* See alse [code example][1]
* ##### Example
*
* [1]:http://github.com/nodeca/argparse/blob/master/lib/argument_parser.js#L953
* formatter.startSection(actionGroup.title);
* formatter.addText(actionGroup.description);
* formatter.addArguments(actionGroup._groupActions);
* formatter.endSection();
*
**/

@@ -203,5 +216,7 @@ HelpFormatter.prototype.addText = function (text) {

*
* See alse [code example][1]
* ##### Example
*
* [1]:https://github.com/nodeca/argparse/blob/master/lib/argument_parser.js#L930
* formatter.addUsage(this.usage, this._actions, []);
* return formatter.formatHelp();
*
**/

@@ -259,5 +274,9 @@ HelpFormatter.prototype.addUsage = function (usage, actions, groups, prefix) {

*
* See alse [code example][1]
* ##### Example
*
* [1]:http://github.com/nodeca/argparse/blob/master/lib/argument_parser.js#L953
* formatter.startSection(actionGroup.title);
* formatter.addText(actionGroup.description);
* formatter.addArguments(actionGroup._groupActions);
* formatter.endSection();
*
**/

@@ -280,5 +299,7 @@ HelpFormatter.prototype.addArguments = function (actions) {

*
* See alse [code example][1]
* ##### Example
*
* [1]:https://github.com/nodeca/argparse/blob/master/lib/argument_parser.js#L964
* formatter.addText(this.epilog);
* return formatter.formatHelp();
*
**/

@@ -741,6 +762,9 @@ HelpFormatter.prototype.formatHelp = function () {

var lines = [];
var wrapped;
var delimiters = [" ", ".", ",", "!", "?"];
var re = new RegExp('[' + delimiters.join('') + '][^' + delimiters.join('') + ']*$');
text = text.replace(/[\n\|\t]/g, ' ');
text = _.str.strip(text);
text = text.replace(this._whitespaceMatcher, ' ');
text = _.str.strip(text);

@@ -757,8 +781,15 @@ // Wraps the single paragraph in text (a string) so every line

var wrapEnd = width;
while (wrapStart < line.length) {
wrapped = line.split(wrapStart, wrapEnd);
lines.push(wrapped);
wrapStart += width;
var delimiterIndex = 0;
while (wrapEnd <= line.length) {
if (wrapEnd !== line.length && delimiters.indexOf(line[wrapEnd] < -1)) {
delimiterIndex = (re.exec(line.substring(wrapStart, wrapEnd)) || {}).index;
wrapEnd = wrapStart + delimiterIndex + 1;
}
lines.push(line.substring(wrapStart, wrapEnd));
wrapStart = wrapEnd;
wrapEnd += width;
}
if (wrapStart < line.length) {
lines.push(line.substring(wrapStart, wrapEnd));
}
});

@@ -765,0 +796,0 @@

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

@@ -6,0 +6,0 @@ "homepage" : "https://github.com/nodeca/argparse",

@@ -39,3 +39,3 @@ argparse

);
var args = parser.parseArgs('-f 1 -b2'.split(' '));
var args = parser.parseArgs();
console.dir(args);

@@ -214,2 +214,5 @@ ```

var args = parser.parseArgs();
console.dir(args);
```

@@ -216,0 +219,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