New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clap

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clap - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

70

index.js

@@ -79,3 +79,3 @@ var MAX_LINE_WIDTH = process.stdout.columns || 200;

if (left)
throw new ParseError('Bad parameter description: ' + str);
throw new SyntaxError('Bad parameter description: ' + str);

@@ -89,7 +89,8 @@ return result.args.length ? result : false;

var ParseError = function(message){
var SyntaxError = function(message){
this.message = message;
};
ParseError.prototype = Object.create(Error.prototype);
ParseError.prototype.name = 'ParseError';
SyntaxError.prototype = Object.create(Error.prototype);
SyntaxError.prototype.name = 'SyntaxError';
SyntaxError.prototype.clap = true;

@@ -140,3 +141,3 @@ /**

if (!this.long)
throw new ParseError('Usage has no long name: ' + usage);
throw new SyntaxError('Usage has no long name: ' + usage);

@@ -146,3 +147,3 @@ try {

} catch(e) {
throw new ParseError('Bad paramenter description in usage for option: ' + usage, e);
throw new SyntaxError('Bad paramenter description in usage for option: ' + usage, e);
}

@@ -160,3 +161,3 @@

if (left)
throw new ParseError('Bad usage description for option: ' + usage);
throw new SyntaxError('Bad usage description for option: ' + usage);

@@ -196,3 +197,3 @@ if (!this.name)

// if (option.bool && arguments.length > 2)
// throw new ParseError('bool flags can\'t has default value or validator');
// throw new SyntaxError('bool flags can\'t has default value or validator');

@@ -238,3 +239,3 @@ if (arguments.length == 3)

if (commandOption)
throw new ParseError('Short option name -' + option.short + ' already in use by ' + commandOption.usage + ' ' + commandOption.description);
throw new SyntaxError('Short option name -' + option.short + ' already in use by ' + commandOption.usage + ' ' + commandOption.description);

@@ -248,3 +249,3 @@ command.short[option.short] = option;

if (commandOption)
throw new ParseError('Long option --' + option.long + ' already in use by ' + commandOption.usage + ' ' + commandOption.description);
throw new SyntaxError('Long option --' + option.long + ' already in use by ' + commandOption.usage + ' ' + commandOption.description);

@@ -257,3 +258,3 @@ command.long[option.long] = option;

if (commandOption)
throw new ParseError('Name option ' + option.camelName + ' already in use by ' + commandOption.usage + ' ' + commandOption.description);
throw new SyntaxError('Name option ' + option.camelName + ' already in use by ' + commandOption.usage + ' ' + commandOption.description);

@@ -295,3 +296,3 @@ command.options[option.camelName] = option;

if (params.length < option.minArgsCount)
throw new ParseError('Option ' + token + ' should be used with at least ' + option.minArgsCount + ' argument(s)\nUsage: ' + option.usage);
throw new SyntaxError('Option ' + token + ' should be used with at least ' + option.minArgsCount + ' argument(s)\nUsage: ' + option.usage);
}

@@ -373,3 +374,3 @@ else

else
throw new ParseError('Unknown option: ' + token);
throw new SyntaxError('Unknown option: ' + token);
}

@@ -384,3 +385,3 @@

if (!/^-[a-zA-Z]+$/.test(token))
throw new ParseError('Wrong short option sequence: ' + token);
throw new SyntaxError('Wrong short option sequence: ' + token);

@@ -392,3 +393,3 @@ if (token.length == 2)

if (!option)
throw new ParseError('Unknown short option name: -' + token[1]);
throw new SyntaxError('Unknown short option name: -' + token[1]);

@@ -406,6 +407,6 @@ // single option

if (!option)
throw new ParseError('Unknown short option name: -' + token[j]);
throw new SyntaxError('Unknown short option name: -' + token[j]);
if (option.maxArgsCount)
throw new ParseError('Non-boolean option -' + token[j] + ' can\'t be used in short option sequence: ' + token);
throw new SyntaxError('Non-boolean option -' + token[j] + ' can\'t be used in short option sequence: ' + token);

@@ -428,3 +429,3 @@ processOption(option, command);

if (command.params && resultToken.args.length < command.params.minArgsCount)
throw new ParseError('Missed required argument(s) for command `' + command.name + '`');
throw new SyntaxError('Missed required argument(s) for command `' + command.name + '`');

@@ -456,3 +457,3 @@ // switch control to another command

else
throw new ParseError('Unknown command: ' + token);
throw new SyntaxError('Unknown command: ' + token);
}

@@ -477,3 +478,3 @@ }

if (command.params && resultToken.args.length < command.params.minArgsCount)
throw new ParseError('Missed required argument(s) for command `' + command.name + '`');
throw new SyntaxError('Missed required argument(s) for command `' + command.name + '`');
}

@@ -489,6 +490,6 @@

if (this[property] !== noop)
throw new ParseError('Method `' + name + '` could be invoked only once');
throw new SyntaxError('Method `' + name + '` could be invoked only once');
if (typeof fn != 'function')
throw new ParseError('Value for `' + name + '` method should be a function');
throw new SyntaxError('Value for `' + name + '` method should be a function');

@@ -512,3 +513,3 @@ this[property] = fn;

} catch(e) {
throw new ParseError('Bad paramenter description in command definition: ' + this.name + ' ' + params);
throw new SyntaxError('Bad paramenter description in command definition: ' + this.name + ' ' + params);
}

@@ -539,2 +540,3 @@

values: null,
defaults_: null,
suggestions: null,

@@ -549,3 +551,2 @@

args_: noop,
defaults_: null,

@@ -559,3 +560,3 @@ option: function(usage, description, opt_1, opt_2){

if (typeof fn != 'function')
throw new ParseError('fn should be a function');
throw new SyntaxError('fn should be a function');

@@ -594,3 +595,3 @@ var command = this;

if (!this.hasOption(name))
throw new ParseError('Option `' + name + '` is not defined');
throw new SyntaxError('Option `' + name + '` is not defined');

@@ -632,3 +633,3 @@ var option = this.options[name];

if (!/^[a-zA-Z][a-zA-Z0-9\-\_]*$/.test(name))
throw new ParseError('Wrong command name: ' + name);
throw new SyntaxError('Wrong command name: ' + name);
}

@@ -655,3 +656,3 @@

if (this.version_)
throw new ParseError('Version for command could be set only once');
throw new SyntaxError('Version for command could be set only once');

@@ -673,3 +674,3 @@ this.version_ = version;

if (this.description_)
throw new ParseError('Description for command could be set only once');
throw new SyntaxError('Description for command could be set only once');

@@ -687,2 +688,7 @@ this.description_ = description;

extend: function(fn){
fn(this);
return this;
},
parse: function(args, suggest){

@@ -914,3 +920,3 @@ var suggestions;

Error: ParseError,
Error: SyntaxError,
Argument: Argument,

@@ -922,6 +928,6 @@ Command: Command,

if (errorHandler)
throw new ParseError('Error handler should be set only once');
throw new SyntaxError('Error handler should be set only once');
if (typeof fn != 'function')
throw new ParseError('Error handler should be a function');
throw new SyntaxError('Error handler should be a function');

@@ -928,0 +934,0 @@ errorHandler = fn;

@@ -6,4 +6,10 @@ {

"author": "Roman Dvornov <rdvornov@gmail.com>",
"version": "1.0.6",
"keywords": ["cli", "command", "option", "argument", "completion"],
"version": "1.0.7",
"keywords": [
"cli",
"command",
"option",
"argument",
"completion"
],
"homepage": "https://github.com/lahmatiy/clap",

@@ -15,3 +21,5 @@ "repository": {

"main": "index",
"files": ["index.js"],
"files": [
"index.js"
],
"engines": {

@@ -18,0 +26,0 @@ "node": ">=0.10.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