Huge News!Announcing our $40M Series B led by Abstract Ventures.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 3.0.0 to 3.1.0

6

lib/command.js

@@ -14,3 +14,7 @@ import getCommandHelp from './help.js';

export default class Command {
constructor(usage = '') {
constructor(usage = '', ...rest) {
if (rest.length > 0) {
throw new Error('Second parameter in Command constructor is deprecated, use first parameter to define args instead, i.e. command("name [arg1] [arg2]")');
}
const [name, params] = usage.trim().split(/(\s+.*)$/);

@@ -17,0 +21,0 @@

9

lib/index.js

@@ -12,6 +12,7 @@ import { basename, extname } from 'path';

function command(name, params, config) {
name = name || nameFromProcessArgv() || 'command';
return new Command(name, params, config);
function command(usageOrCommand, ...rest) {
return new Command(
usageOrCommand || nameFromProcessArgv() || 'command',
...rest
);
}

@@ -18,0 +19,0 @@

@@ -83,4 +83,10 @@ import CliError from './parse-argv-error.js';

// special case, use - as a value for an arg
if (token === '-' && context.args.length < command.params.maxCount) {
context.args.push(token);
continue;
}
if (token[0] === '-') {
if (token[1] === '-' || token.length === 2) {
if (token[1] === '-') {
// long option

@@ -101,3 +107,3 @@ const option = command.getOption(token);

if (!/^-[a-zA-Z0-9]+$/.test(token)) {
throw new CliError(`Bad short option sequence: ${token}`);
throw new CliError(`Bad short options sequence: ${token}`);
}

@@ -109,3 +115,3 @@

if (option === null) {
throw new CliError(`Unknown option "${token[j]}" in short option sequence: ${token}`);
throw new CliError(`Unknown option "${token[j]}" in short options sequence: ${token}`);
}

@@ -115,3 +121,3 @@

throw new CliError(
`Non-boolean option "-${token[j]}" can\'t be used in short option sequence: ${token}`
`Non-boolean option "-${token[j]}" can\'t be used in short options sequence: ${token}`
);

@@ -118,0 +124,0 @@ }

{
"name": "clap",
"title": "Command line argument parser",
"version": "3.1.0",
"description": "Command line argument parser",

@@ -8,3 +8,2 @@ "author": "Roman Dvornov <rdvornov@gmail.com>",

"license": "MIT",
"version": "3.0.0",
"keywords": [

@@ -38,7 +37,7 @@ "cli",

"devDependencies": {
"c8": "^7.10.0",
"eslint": "^8.4.1",
"mocha": "^9.1.3",
"rollup": "^2.61.1",
"test-console": "^1.1.0"
"c8": "^7.11.0",
"eslint": "^8.8.0",
"mocha": "^9.2.0",
"rollup": "^2.67.1",
"test-console": "^2.0.0"
},

@@ -50,3 +49,4 @@ "scripts": {

"test:cjs": "mocha cjs-test --reporter ${REPORTER:-progress}",
"build": "npm run esm-to-cjs",
"watch": "npm run build -- --watch",
"build": "npm run esm-to-cjs --",
"build-and-test": "npm run esm-to-cjs-and-test",

@@ -53,0 +53,0 @@ "esm-to-cjs": "node scripts/esm-to-cjs",

@@ -49,3 +49,3 @@ [![NPM version](https://img.shields.io/npm/v/clap.svg)](https://www.npmjs.com/package/clap)

.end()
.command('another-command')
.command('another-command [arg1] [arg2]')
// ...

@@ -52,0 +52,0 @@ .command('level3-command')

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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