Socket
Socket
Sign inDemoInstall

commander

Package Overview
Dependencies
0
Maintainers
6
Versions
115
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.0-0 to 8.0.0-1

lib/argument.js

16

CHANGELOG.md

@@ -11,2 +11,15 @@ # Changelog

## [8.0.0-1] (2021-05-30)
### Added
- `.addArgument()` ([#1490])
- `Argument` supports `.choices()` ([#1525])
- client typing of `.opts()` return type using TypeScript generics ([#1539])
### Changed
- refactor `index.tab` into a file per class ([#1522])
- update dependencies
## [8.0.0-0] (2021-05-23)

@@ -317,2 +330,5 @@

[#1521]: https://github.com/tj/commander.js/pull/1521
[#1522]: https://github.com/tj/commander.js/pull/1522
[#1525]: https://github.com/tj/commander.js/pull/1525
[#1539]: https://github.com/tj/commander.js/pull/1539

@@ -319,0 +335,0 @@ [Unreleased]: https://github.com/tj/commander.js/compare/master...develop

25

package.json
{
"name": "commander",
"version": "8.0.0-0",
"version": "8.0.0-1",
"description": "the complete solution for node.js command-line programs",

@@ -22,3 +22,3 @@ "keywords": [

"scripts": {
"lint": "eslint index.js esm.mjs \"tests/**/*.js\"",
"lint": "eslint index.js esm.mjs \"lib/*.js\" \"tests/**/*.js\"",
"typescript-lint": "eslint typings/*.ts tests/*.ts",

@@ -28,3 +28,3 @@ "test": "jest && npm run test-typings",

"test-typings": "tsd",
"typescript-checkJS": "tsc --allowJS --checkJS index.js --noEmit",
"typescript-checkJS": "tsc --allowJS --checkJS index.js lib/*.js --noEmit",
"test-all": "npm run test && npm run lint && npm run typescript-lint && npm run typescript-checkJS && npm run test-esm"

@@ -35,2 +35,3 @@ },

"index.js",
"lib/*.js",
"esm.mjs",

@@ -44,13 +45,13 @@ "typings/index.d.ts",

"@types/jest": "^26.0.23",
"@types/node": "^14.17.0",
"@typescript-eslint/eslint-plugin": "^4.24.0",
"@typescript-eslint/parser": "^4.24.0",
"eslint": "^7.26.0",
"eslint-config-standard": "^16.0.2",
"@types/node": "^14.17.1",
"@typescript-eslint/eslint-plugin": "^4.25.0",
"@typescript-eslint/parser": "^4.25.0",
"eslint": "^7.27.0",
"eslint-config-standard": "^16.0.3",
"eslint-plugin-jest": "^24.3.6",
"jest": "^26.6.3",
"jest": "^27.0.1",
"standard": "^16.0.3",
"ts-jest": "^26.5.6",
"tsd": "^0.15.1",
"typescript": "^4.2.4"
"ts-jest": "^27.0.1",
"tsd": "^0.16.0",
"typescript": "^4.3.2"
},

@@ -57,0 +58,0 @@ "types": "typings/index.d.ts",

@@ -25,4 +25,5 @@ # Commander.js

- [Commands](#commands)
- [Specify the argument syntax](#specify-the-argument-syntax)
- [Custom argument processing](#custom-argument-processing)
- [Command-arguments](#command-arguments)
- [More configuration](#more-configuration-1)
- [Custom argument processing](#custom-argument-processing)
- [Action handler](#action-handler)

@@ -37,3 +38,3 @@ - [Stand-alone executable (sub)commands](#stand-alone-executable-subcommands)

- [.addHelpCommand()](#addhelpcommand)
- [More configuration](#more-configuration-1)
- [More configuration](#more-configuration-2)
- [Custom event listeners](#custom-event-listeners)

@@ -136,8 +137,5 @@ - [Bits and pieces](#bits-and-pieces)

```bash
$ pizza-options -d
{ debug: true, small: undefined, pizzaType: undefined }
pizza details:
$ pizza-options -p
error: option '-p, --pizza-type <type>' argument missing
$ pizza-options -ds -p vegetarian
$ pizza-options -d -s -p vegetarian
{ debug: true, small: true, pizzaType: 'vegetarian' }

@@ -437,3 +435,3 @@ pizza details:

### Specify the argument syntax
### Command-arguments

@@ -448,3 +446,2 @@ For subcommands, you can specify the argument syntax in the call to `.command()` (as shown above). This

Example file: [argument.js](./examples/argument.js)

@@ -485,4 +482,16 @@

### Custom argument processing
#### More configuration
There are some additional features available by constructing an `Argument` explicitly for less common cases.
Example file: [arguments-extra.js](./examples/arguments-extra.js)
```js
program
.addArgument(new commander.Argument('<drink-size>', 'drink cup size').choices(['small', 'medium', 'large']))
.addArgument(new commander.Argument('[timeout]', 'timeout in seconds').default(60, 'one minute'))
```
#### Custom argument processing
You may specify a function to do custom processing of command-arguments before they are passed to the action handler.

@@ -489,0 +498,0 @@ The callback function receives two parameters, the user specified command-argument and the previous value for the argument.

@@ -49,6 +49,22 @@ // Type definitions for commander

/**
* Return argument name.
*/
name(): string;
/**
* Return argument name.
*/
name(): string;
/**
* Set the default value, and optionally supply the description to be displayed in the help.
*/
default(value: unknown, description?: string): this;
/**
* Set the custom handler for processing CLI command arguments into argument values.
*/
argParser<T>(fn: (value: string, previous: T) => T): this;
/**
* Only allow argument value to be one of choices.
*/
choices(values: string[]): this;
}

@@ -471,4 +487,4 @@

*/
storeOptionsAsProperties(): this & OptionValues;
storeOptionsAsProperties(storeAsProperties: true): this & OptionValues;
storeOptionsAsProperties<T extends OptionValues>(): this & T;
storeOptionsAsProperties<T extends OptionValues>(storeAsProperties: true): this & T;
storeOptionsAsProperties(storeAsProperties?: boolean): this;

@@ -583,3 +599,3 @@

*/
opts(): OptionValues;
opts<T extends OptionValues>(): T;

@@ -586,0 +602,0 @@ /**

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc