Socket
Socket
Sign inDemoInstall

commander

Package Overview
Dependencies
Maintainers
4
Versions
115
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

commander - npm Package Compare versions

Comparing version 12.0.0 to 12.1.0

14

lib/argument.js

@@ -53,3 +53,3 @@ const { InvalidArgumentError } = require('./error.js');

/**
* @package internal use only
* @package
*/

@@ -102,3 +102,5 @@

if (!this.argChoices.includes(arg)) {
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
throw new InvalidArgumentError(
`Allowed choices are ${this.argChoices.join(', ')}.`,
);
}

@@ -115,2 +117,4 @@ if (this.variadic) {

* Make argument required.
*
* @returns {Argument}
*/

@@ -124,2 +128,4 @@ argRequired() {

* Make argument optional.
*
* @returns {Argument}
*/

@@ -143,5 +149,3 @@ argOptional() {

return arg.required
? '<' + nameOutput + '>'
: '[' + nameOutput + ']';
return arg.required ? '<' + nameOutput + '>' : '[' + nameOutput + ']';
}

@@ -148,0 +152,0 @@

/**
* CommanderError class
* @class
*/

@@ -11,3 +10,2 @@ class CommanderError extends Error {

* @param {string} message human-readable description of the error
* @constructor
*/

@@ -27,3 +25,2 @@ constructor(exitCode, code, message) {

* InvalidArgumentError class
* @class
*/

@@ -34,3 +31,2 @@ class InvalidArgumentError extends CommanderError {

* @param {string} [message] explanation of why argument is invalid
* @constructor
*/

@@ -37,0 +33,0 @@ constructor(message) {

@@ -28,3 +28,3 @@ const { humanReadableArgName } = require('./argument.js');

visibleCommands(cmd) {
const visibleCommands = cmd.commands.filter(cmd => !cmd._hidden);
const visibleCommands = cmd.commands.filter((cmd) => !cmd._hidden);
const helpCommand = cmd._getHelpCommand();

@@ -36,3 +36,3 @@ if (helpCommand && !helpCommand._hidden) {

visibleCommands.sort((a, b) => {
// @ts-ignore: overloaded return type
// @ts-ignore: because overloaded return type
return a.name().localeCompare(b.name());

@@ -49,3 +49,3 @@ });

* @param {Option} b
* @returns number
* @returns {number}
*/

@@ -55,3 +55,5 @@ compareOptions(a, b) {

// WYSIWYG for order displayed in help. Short used for comparison if present. No special handling for negated.
return option.short ? option.short.replace(/^-/, '') : option.long.replace(/^--/, '');
return option.short
? option.short.replace(/^-/, '')
: option.long.replace(/^--/, '');
};

@@ -79,5 +81,9 @@ return getSortKey(a).localeCompare(getSortKey(b));

} else if (helpOption.long && !removeLong) {
visibleOptions.push(cmd.createOption(helpOption.long, helpOption.description));
visibleOptions.push(
cmd.createOption(helpOption.long, helpOption.description),
);
} else if (helpOption.short && !removeShort) {
visibleOptions.push(cmd.createOption(helpOption.short, helpOption.description));
visibleOptions.push(
cmd.createOption(helpOption.short, helpOption.description),
);
}

@@ -102,4 +108,10 @@ }

const globalOptions = [];
for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
const visibleOptions = ancestorCmd.options.filter((option) => !option.hidden);
for (
let ancestorCmd = cmd.parent;
ancestorCmd;
ancestorCmd = ancestorCmd.parent
) {
const visibleOptions = ancestorCmd.options.filter(
(option) => !option.hidden,
);
globalOptions.push(...visibleOptions);

@@ -123,4 +135,5 @@ }

if (cmd._argsDescription) {
cmd.registeredArguments.forEach(argument => {
argument.description = argument.description || cmd._argsDescription[argument.name()] || '';
cmd.registeredArguments.forEach((argument) => {
argument.description =
argument.description || cmd._argsDescription[argument.name()] || '';
});

@@ -130,3 +143,3 @@ }

// If there are any arguments with a description then return all the arguments.
if (cmd.registeredArguments.find(argument => argument.description)) {
if (cmd.registeredArguments.find((argument) => argument.description)) {
return cmd.registeredArguments;

@@ -146,7 +159,11 @@ }

// Legacy. Ignores custom usage string, and nested commands.
const args = cmd.registeredArguments.map(arg => humanReadableArgName(arg)).join(' ');
return cmd._name +
const args = cmd.registeredArguments
.map((arg) => humanReadableArgName(arg))
.join(' ');
return (
cmd._name +
(cmd._aliases[0] ? '|' + cmd._aliases[0] : '') +
(cmd.options.length ? ' [options]' : '') + // simplistic check for non-help option
(args ? ' ' + args : '');
(args ? ' ' + args : '')
);
}

@@ -246,3 +263,7 @@

let ancestorCmdNames = '';
for (let ancestorCmd = cmd.parent; ancestorCmd; ancestorCmd = ancestorCmd.parent) {
for (
let ancestorCmd = cmd.parent;
ancestorCmd;
ancestorCmd = ancestorCmd.parent
) {
ancestorCmdNames = ancestorCmd.name() + ' ' + ancestorCmdNames;

@@ -261,3 +282,3 @@ }

commandDescription(cmd) {
// @ts-ignore: overloaded return type
// @ts-ignore: because overloaded return type
return cmd.description();

@@ -275,3 +296,3 @@ }

subcommandDescription(cmd) {
// @ts-ignore: overloaded return type
// @ts-ignore: because overloaded return type
return cmd.summary() || cmd.description();

@@ -293,3 +314,4 @@ }

// use stringify to match the display of the default value
`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
`choices: ${option.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
);
}

@@ -299,6 +321,10 @@ if (option.defaultValue !== undefined) {

// but show true/false for boolean option as may be for hand-rolled env or config processing.
const showDefault = option.required || option.optional ||
const showDefault =
option.required ||
option.optional ||
(option.isBoolean() && typeof option.defaultValue === 'boolean');
if (showDefault) {
extraInfo.push(`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`);
extraInfo.push(
`default: ${option.defaultValueDescription || JSON.stringify(option.defaultValue)}`,
);
}

@@ -332,6 +358,9 @@ }

// use stringify to match the display of the default value
`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`);
`choices: ${argument.argChoices.map((choice) => JSON.stringify(choice)).join(', ')}`,
);
}
if (argument.defaultValue !== undefined) {
extraInfo.push(`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`);
extraInfo.push(
`default: ${argument.defaultValueDescription || JSON.stringify(argument.defaultValue)}`,
);
}

@@ -364,3 +393,7 @@ if (extraInfo.length > 0) {

const fullText = `${term.padEnd(termWidth + itemSeparatorWidth)}${description}`;
return helper.wrap(fullText, helpWidth - itemIndentWidth, termWidth + itemSeparatorWidth);
return helper.wrap(
fullText,
helpWidth - itemIndentWidth,
termWidth + itemSeparatorWidth,
);
}

@@ -379,3 +412,6 @@ return term;

if (commandDescription.length > 0) {
output = output.concat([helper.wrap(commandDescription, helpWidth, 0), '']);
output = output.concat([
helper.wrap(commandDescription, helpWidth, 0),
'',
]);
}

@@ -385,3 +421,6 @@

const argumentList = helper.visibleArguments(cmd).map((argument) => {
return formatItem(helper.argumentTerm(argument), helper.argumentDescription(argument));
return formatItem(
helper.argumentTerm(argument),
helper.argumentDescription(argument),
);
});

@@ -394,3 +433,6 @@ if (argumentList.length > 0) {

const optionList = helper.visibleOptions(cmd).map((option) => {
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
return formatItem(
helper.optionTerm(option),
helper.optionDescription(option),
);
});

@@ -402,7 +444,16 @@ if (optionList.length > 0) {

if (this.showGlobalOptions) {
const globalOptionList = helper.visibleGlobalOptions(cmd).map((option) => {
return formatItem(helper.optionTerm(option), helper.optionDescription(option));
});
const globalOptionList = helper
.visibleGlobalOptions(cmd)
.map((option) => {
return formatItem(
helper.optionTerm(option),
helper.optionDescription(option),
);
});
if (globalOptionList.length > 0) {
output = output.concat(['Global Options:', formatList(globalOptionList), '']);
output = output.concat([
'Global Options:',
formatList(globalOptionList),
'',
]);
}

@@ -413,3 +464,6 @@ }

const commandList = helper.visibleCommands(cmd).map((cmd) => {
return formatItem(helper.subcommandTerm(cmd), helper.subcommandDescription(cmd));
return formatItem(
helper.subcommandTerm(cmd),
helper.subcommandDescription(cmd),
);
});

@@ -436,3 +490,3 @@ if (commandList.length > 0) {

helper.longestSubcommandTermLength(cmd, helper),
helper.longestArgumentTermLength(cmd, helper)
helper.longestArgumentTermLength(cmd, helper),
);

@@ -455,3 +509,4 @@ }

// Full \s characters, minus the linefeeds.
const indents = ' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff';
const indents =
' \\f\\t\\v\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000\ufeff';
// Detect manually wrapped and indented strings by searching for line break followed by spaces.

@@ -471,8 +526,16 @@ const manualIndent = new RegExp(`[\\n][${indents}]+`);

// or as much text as will fit in column, or excess text up to first break.
const regex = new RegExp(`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`, 'g');
const regex = new RegExp(
`\n|.{1,${columnWidth - 1}}([${breaks}]|$)|[^${breaks}]+?([${breaks}]|$)`,
'g',
);
const lines = columnText.match(regex) || [];
return leadingStr + lines.map((line, i) => {
if (line === '\n') return ''; // preserve empty lines
return ((i > 0) ? indentString : '') + line.trimEnd();
}).join('\n');
return (
leadingStr +
lines
.map((line, i) => {
if (line === '\n') return ''; // preserve empty lines
return (i > 0 ? indentString : '') + line.trimEnd();
})
.join('\n')
);
}

@@ -479,0 +542,0 @@ }

@@ -96,3 +96,3 @@ const { InvalidArgumentError } = require('./error.js');

*
* @param {Object} impliedOptionValues
* @param {object} impliedOptionValues
* @return {Option}

@@ -162,3 +162,3 @@ */

/**
* @package internal use only
* @package
*/

@@ -185,3 +185,5 @@

if (!this.argChoices.includes(arg)) {
throw new InvalidArgumentError(`Allowed choices are ${this.argChoices.join(', ')}.`);
throw new InvalidArgumentError(
`Allowed choices are ${this.argChoices.join(', ')}.`,
);
}

@@ -225,3 +227,3 @@ if (this.variadic) {

* @return {boolean}
* @package internal use only
* @package
*/

@@ -239,3 +241,3 @@

* @return {boolean}
* @package internal use only
* @package
*/

@@ -263,3 +265,3 @@

this.dualOptions = new Set();
options.forEach(option => {
options.forEach((option) => {
if (option.negate) {

@@ -291,3 +293,3 @@ this.negativeOptions.set(option.attributeName(), option);

const preset = this.negativeOptions.get(optionKey).presetArg;
const negativeValue = (preset !== undefined) ? preset : false;
const negativeValue = preset !== undefined ? preset : false;
return option.negate === (negativeValue === value);

@@ -323,3 +325,4 @@ }

const flagParts = flags.split(/[ |,]+/);
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1])) shortFlag = flagParts.shift();
if (flagParts.length > 1 && !/^[[<]/.test(flagParts[1]))
shortFlag = flagParts.shift();
longFlag = flagParts.shift();

@@ -326,0 +329,0 @@ // Add support for lone short flag without significantly changing parsing!

@@ -9,3 +9,4 @@ const maxDistance = 3;

// Quick early exit, return worst case.
if (Math.abs(a.length - b.length) > maxDistance) return Math.max(a.length, b.length);
if (Math.abs(a.length - b.length) > maxDistance)
return Math.max(a.length, b.length);

@@ -36,3 +37,3 @@ // distance between prefix substrings of a and b

d[i][j - 1] + 1, // insertion
d[i - 1][j - 1] + cost // substitution
d[i - 1][j - 1] + cost, // substitution
);

@@ -65,3 +66,3 @@ // transposition

word = word.slice(2);
candidates = candidates.map(candidate => candidate.slice(2));
candidates = candidates.map((candidate) => candidate.slice(2));
}

@@ -91,3 +92,3 @@

if (searchingOptions) {
similar = similar.map(candidate => `--${candidate}`);
similar = similar.map((candidate) => `--${candidate}`);
}

@@ -94,0 +95,0 @@

{
"name": "commander",
"version": "12.0.0",
"version": "12.1.0",
"description": "the complete solution for node.js command-line programs",

@@ -22,10 +22,14 @@ "keywords": [

"scripts": {
"lint": "npm run lint:javascript && npm run lint:typescript",
"lint:javascript": "eslint index.js esm.mjs \"lib/*.js\" \"tests/**/*.js\"",
"lint:typescript": "eslint typings/*.ts tests/*.ts",
"test": "jest && npm run typecheck-ts",
"test-esm": "node ./tests/esm-imports-test.mjs",
"typecheck-ts": "tsd && tsc -p tsconfig.ts.json",
"typecheck-js": "tsc -p tsconfig.js.json",
"test-all": "npm run test && npm run lint && npm run typecheck-js && npm run test-esm"
"check": "npm run check:type && npm run check:lint && npm run check:format",
"check:format": "prettier --check .",
"check:lint": "eslint .",
"check:type": "npm run check:type:js && npm run check:type:ts",
"check:type:ts": "tsd && tsc -p tsconfig.ts.json",
"check:type:js": "tsc -p tsconfig.js.json",
"fix": "npm run fix:lint && npm run fix:format",
"fix:format": "prettier --write .",
"fix:lint": "eslint --fix .",
"test": "jest && npm run check:type:ts",
"test-all": "jest && npm run test-esm && npm run check",
"test-esm": "node ./tests/esm-imports-test.mjs"
},

@@ -60,17 +64,17 @@ "files": [

"devDependencies": {
"@eslint/js": "^8.56.0",
"@types/jest": "^29.2.4",
"@types/node": "^20.2.5",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"eslint": "^8.30.0",
"eslint-config-standard": "^17.0.0",
"eslint-config-standard-with-typescript": "^40.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.7",
"eslint-plugin-n": "^16.2.0",
"eslint-plugin-promise": "^6.1.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-jest": "^28.3.0",
"eslint-plugin-jsdoc": "^48.1.0",
"globals": "^13.24.0",
"jest": "^29.3.1",
"prettier": "^3.2.5",
"prettier-plugin-jsdoc": "^1.3.0",
"ts-jest": "^29.0.3",
"tsd": "^0.30.4",
"typescript": "^5.0.4"
"tsd": "^0.31.0",
"typescript": "^5.0.4",
"typescript-eslint": "^7.0.1"
},

@@ -77,0 +81,0 @@ "types": "typings/index.d.ts",

@@ -958,9 +958,9 @@ # Commander.js

The first argument to `.parse` is the array of strings to parse. You may omit the parameter to implicitly use `process.argv`.
Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
If the arguments follow different conventions than node you can pass a `from` option in the second parameter:
Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
- 'node': default, `argv[0]` is the application and `argv[1]` is the script being run, with user parameters after that
- 'electron': `argv[1]` varies depending on whether the electron application is packaged
- 'user': all of the arguments from the user
- `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
- `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
- `'user'`: just user arguments

@@ -970,7 +970,9 @@ For example:

```js
program.parse(process.argv); // Explicit, node conventions
program.parse(); // Implicit, and auto-detect electron
program.parse(['-f', 'filename'], { from: 'user' });
program.parse(); // parse process.argv and auto-detect electron and special node flags
program.parse(process.argv); // assume argv[0] is app and argv[1] is script
program.parse(['--port', '80'], { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
```
Use parseAsync instead of parse if any of your action handlers are async.
If you want to parse multiple times, create a new program each time. Calling parse does not clear out any previous state.

@@ -977,0 +979,0 @@

@@ -14,3 +14,5 @@ // Type definitions for commander

// - https://github.com/sindresorhus/type-fest/blob/main/source/primitive.d.ts
type LiteralUnion<LiteralType, BaseType extends string | number> = LiteralType | (BaseType & Record<never, never>);
type LiteralUnion<LiteralType, BaseType extends string | number> =
| LiteralType
| (BaseType & Record<never, never>);

@@ -28,3 +30,2 @@ export class CommanderError extends Error {

* @param message - human-readable description of the error
* @constructor
*/

@@ -38,3 +39,2 @@ constructor(exitCode: number, code: string, message: string);

* @param message - explanation of why argument is invalid
* @constructor
*/

@@ -45,3 +45,4 @@ constructor(message: string);

export interface ErrorOptions { // optional parameter for error()
export interface ErrorOptions {
// optional parameter for error()
/** an id string representing the error */

@@ -170,7 +171,2 @@ code?: string;

/**
* Calculate the full description, including defaultValue etc.
*/
fullDescription(): string;
/**
* Set the custom handler for processing CLI option arguments into option values.

@@ -265,3 +261,8 @@ */

*/
wrap(str: string, width: number, indent: number, minColumnWidth?: number): string;
wrap(
str: string,
width: number,
indent: number,
minColumnWidth?: number,
): string;

@@ -276,6 +277,8 @@ /** Generate the built-in help text. */

}
export interface HelpContext { // optional parameter for .help() and .outputHelp()
export interface HelpContext {
// optional parameter for .help() and .outputHelp()
error: boolean;
}
export interface AddHelpTextContext { // passed to text function used with .addHelpText()
export interface AddHelpTextContext {
// passed to text function used with .addHelpText()
error: boolean;

@@ -290,3 +293,2 @@ command: Command;

outputError?(str: string, write: (str: string) => void): void;
}

@@ -297,3 +299,5 @@

// The source is a string so author can define their own too.
export type OptionValueSource = LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string> | undefined;
export type OptionValueSource =
| LiteralUnion<'default' | 'config' | 'env' | 'cli' | 'implied', string>
| undefined;

@@ -346,3 +350,6 @@ export type OptionValues = Record<string, any>;

*/
command(nameAndArgs: string, opts?: CommandOptions): ReturnType<this['createCommand']>;
command(
nameAndArgs: string,
opts?: CommandOptions,
): ReturnType<this['createCommand']>;
/**

@@ -366,3 +373,7 @@ * Define a command, implemented in a separate executable file.

*/
command(nameAndArgs: string, description: string, opts?: ExecutableCommandOptions): this;
command(
nameAndArgs: string,
description: string,
opts?: ExecutableCommandOptions,
): this;

@@ -408,3 +419,8 @@ /**

*/
argument<T>(flags: string, description: string, fn: (value: string, previous: T) => T, defaultValue?: T): this;
argument<T>(
flags: string,
description: string,
fn: (value: string, previous: T) => T,
defaultValue?: T,
): this;
argument(name: string, description?: string, defaultValue?: unknown): this;

@@ -459,3 +475,9 @@

*/
hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;
hook(
event: HookEvent,
listener: (
thisCommand: Command,
actionCommand: Command,
) => void | Promise<void>,
): this;

@@ -560,6 +582,20 @@ /**

*/
option(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
option<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
option(
flags: string,
description?: string,
defaultValue?: string | boolean | string[],
): this;
option<T>(
flags: string,
description: string,
parseArg: (value: string, previous: T) => T,
defaultValue?: T,
): this;
/** @deprecated since v7, instead use choices or a custom function */
option(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
option(
flags: string,
description: string,
regexp: RegExp,
defaultValue?: string | boolean | string[],
): this;

@@ -572,6 +608,20 @@ /**

*/
requiredOption(flags: string, description?: string, defaultValue?: string | boolean | string[]): this;
requiredOption<T>(flags: string, description: string, parseArg: (value: string, previous: T) => T, defaultValue?: T): this;
requiredOption(
flags: string,
description?: string,
defaultValue?: string | boolean | string[],
): this;
requiredOption<T>(
flags: string,
description: string,
parseArg: (value: string, previous: T) => T,
defaultValue?: T,
): this;
/** @deprecated since v7, instead use choices or a custom function */
requiredOption(flags: string, description: string, regexp: RegExp, defaultValue?: string | boolean | string[]): this;
requiredOption(
flags: string,
description: string,
regexp: RegExp,
defaultValue?: string | boolean | string[],
): this;

@@ -601,3 +651,5 @@ /**

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

@@ -618,3 +670,7 @@

*/
setOptionValueWithSource(key: string, value: unknown, source: OptionValueSource): this;
setOptionValueWithSource(
key: string,
value: unknown,
source: OptionValueSource,
): this;

@@ -627,3 +683,3 @@ /**

/**
* Get source of option value. See also .optsWithGlobals().
* Get source of option value. See also .optsWithGlobals().
*/

@@ -684,9 +740,15 @@ getOptionValueSourceWithGlobals(key: string): OptionValueSource | undefined;

*
* The default expectation is that the arguments are from node and have the application as argv[0]
* and the script being run in argv[1], with user parameters after that.
* Use parseAsync instead of parse if any of your action handlers are async.
*
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
*
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
* - `'user'`: just user arguments
*
* @example
* ```
* program.parse(process.argv);
* program.parse(); // implicitly use process.argv and auto-detect node vs electron conventions
* program.parse(); // parse process.argv and auto-detect electron and special node flags
* program.parse(process.argv); // assume argv[0] is app and argv[1] is script
* program.parse(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]

@@ -697,3 +759,3 @@ * ```

*/
parse(argv?: readonly string[], options?: ParseOptions): this;
parse(argv?: readonly string[], parseOptions?: ParseOptions): this;

@@ -703,12 +765,14 @@ /**

*
* Use parseAsync instead of parse if any of your action handlers are async. Returns a Promise.
* Call with no parameters to parse `process.argv`. Detects Electron and special node options like `node --eval`. Easy mode!
*
* The default expectation is that the arguments are from node and have the application as argv[0]
* and the script being run in argv[1], with user parameters after that.
* Or call with an array of strings to parse, and optionally where the user arguments start by specifying where the arguments are `from`:
* - `'node'`: default, `argv[0]` is the application and `argv[1]` is the script being run, with user arguments after that
* - `'electron'`: `argv[0]` is the application and `argv[1]` varies depending on whether the electron application is packaged
* - `'user'`: just user arguments
*
* @example
* ```
* program.parseAsync(process.argv);
* program.parseAsync(); // implicitly use process.argv and auto-detect node vs electron conventions
* program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
* await program.parseAsync(); // parse process.argv and auto-detect electron and special node flags
* await program.parseAsync(process.argv); // assume argv[0] is app and argv[1] is script
* await program.parseAsync(my-args, { from: 'user' }); // just user supplied arguments, nothing special about argv[0]
* ```

@@ -718,3 +782,6 @@ *

*/
parseAsync(argv?: readonly string[], options?: ParseOptions): Promise<this>;
parseAsync(
argv?: readonly string[],
parseOptions?: ParseOptions,
): Promise<this>;

@@ -894,3 +961,6 @@ /**

addHelpText(position: AddHelpTextPosition, text: string): this;
addHelpText(position: AddHelpTextPosition, text: (context: AddHelpTextContext) => string): this;
addHelpText(
position: AddHelpTextPosition,
text: (context: AddHelpTextContext) => string,
): this;

@@ -897,0 +967,0 @@ /**

Sorry, the diff of this file is not supported yet

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

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