Refactor help command implementation to hold actual Command (#2087)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by GitHub · parent 32c05a8 · Browse files · 9 files·+295 added−142 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+295 added−142 removed
- tests:+62 added−7 removed
- other:+233 added−135 removed
Provenance
- Commit
ff08a02- Tree
f520477- Author
John Gee <john@ruru.gen.nz>- Committer
GitHub <noreply@github.com>- Parent
32c05a8
9 files changed+295 added−142 removed
modified:docs/deprecated.md+22 added
13 unmodified lines14 - [InvalidOptionArgumentError](#invalidoptionargumenterror)15 - [Short option flag longer than a single character](#short-option-flag-longer-than-a-single-character)16 - [Import from `commander/esm.mjs`](#import-from-commanderesmmjs)17 - [cmd.\_args](#cmd_args)18+ - [.addHelpCommand(string|boolean|undefined)](#addhelpcommandstringbooleanundefined)19 - [Removed](#removed)20 - [Default import of global Command object](#default-import-of-global-command-object)21 22 ### RegExp .option() parameter182 unmodified lines205 ```206 207 Deprecated from Commander v11.208 209+### .addHelpCommand(string|boolean|undefined)210+211+This was originally used with a variety of parameters, but not by passing a Command object despite the "add" name.212+213+```js214+program.addHelpCommand('assist [command]');215+program.addHelpCommand('assist', 'show assistance');216+program.addHelpCommand(false);217+218+```219+220+In new code you configure the help command with `.helpCommand()`. Or use `.addHelpCommand()` which now takes a Command object, like `.addCommand()`.221+222+```js223+program.helpCommand('assist [command]');224+program.helpCommand('assist', 'show assistance');225+program.helpCommand(false);226+227+program.addHelpCommand(new Command('assist').argument('[command]').description('show assistance'));228+229+```230 ## Removed231 232 ### Default import of global Command object233 19 unmodified linesmodified:lib/command.js+63 added-29 removed
69 unmodified lines70 this._helpFlags = '-h, --help';71 this._helpDescription = 'display help for command';72 this._helpShortFlag = '-h';73 this._helpLongFlag = '--help';74- this._addImplicitHelpCommand = undefined; // Deliberately undefined, not decided whether true or false75- this._helpCommandName = 'help';76- this._helpCommandnameAndArgs = 'help [command]';77- this._helpCommandDescription = 'display help for command';74+ this._addImplicitHelpCommand = undefined; // undecided whether true or false yet, not inherited75+ /** @type {Command} */76+ this._helpCommand = undefined; // lazy initialised, inherited77 this._helpConfiguration = {};78 }79 80 /**10 unmodified lines91 this._helpFlags = sourceCommand._helpFlags;92 this._helpDescription = sourceCommand._helpDescription;93 this._helpShortFlag = sourceCommand._helpShortFlag;94 this._helpLongFlag = sourceCommand._helpLongFlag;96- this._helpCommandName = sourceCommand._helpCommandName;97- this._helpCommandnameAndArgs = sourceCommand._helpCommandnameAndArgs;98- this._helpCommandDescription = sourceCommand._helpCommandDescription;95+ this._helpCommand = sourceCommand._helpCommand;96 this._helpConfiguration = sourceCommand._helpConfiguration;97 this._exitCallback = sourceCommand._exitCallback;98 this._storeOptionsAsProperties = sourceCommand._storeOptionsAsProperties;99 this._combineFlagAndOptionalValue = sourceCommand._combineFlagAndOptionalValue;265 unmodified lines365 return this;366 }367 368 /**372- * Override default decision whether to add implicit help command.369+ * Customise or override default help command. By default a help command is automatically added if your command has subcommands.370 *374- * addHelpCommand() // force on375- * addHelpCommand(false); // force off376- * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details371+ * program.helpCommand('help [cmd]');372+ * program.helpCommand('help [cmd]', 'show help');373+ * program.helpCommand(false); // suppress default help command374+ * program.helpCommand(true); // add help command even if no subcommands375 *376+ * @param {string|boolean} enableOrNameAndArgs - enable with custom name and/or arguments, or boolean to override whether added377+ * @param {string} [description] - custom description378 * @return {Command} `this` command for chaining379 */380 381- addHelpCommand(enableOrNameAndArgs, description) {382- if (enableOrNameAndArgs === false) {383- this._addImplicitHelpCommand = false;384- } else {385- this._addImplicitHelpCommand = true;386- if (typeof enableOrNameAndArgs === 'string') {387- this._helpCommandName = enableOrNameAndArgs.split(' ')[0];388- this._helpCommandnameAndArgs = enableOrNameAndArgs;389- }390- this._helpCommandDescription = description || this._helpCommandDescription;381+ helpCommand(enableOrNameAndArgs, description) {382+ if (typeof enableOrNameAndArgs === 'boolean') {383+ this._addImplicitHelpCommand = enableOrNameAndArgs;384+ return this;385 }386+387+ enableOrNameAndArgs = enableOrNameAndArgs ?? 'help [command]';388+ const [, helpName, helpArgs] = enableOrNameAndArgs.match(/([^ ]+) *(.*)/);389+ const helpDescription = description ?? 'display help for command';390+391+ const helpCommand = this.createCommand(helpName);392+ helpCommand.helpOption(false);393+ if (helpArgs) helpCommand.arguments(helpArgs);394+ if (helpDescription) helpCommand.description(helpDescription);395+396+ this._addImplicitHelpCommand = true;397+ this._helpCommand = helpCommand;398+399 return this;400 }401 402 /**396- * @return {boolean}397- * @package internal use only403+ * Add prepared custom help command.404+ *405+ * @param {(Command|string|boolean)} helpCommand - custom help command, or deprecated enableOrNameAndArgs as for `.helpCommand()`406+ * @param {string} [deprecatedDescription] - deprecated custom description used with custom name only407+ * @return {Command} `this` command for chaining408 */409+ addHelpCommand(helpCommand, deprecatedDescription) {410+ // If not passed an object, call through to helpCommand for backwards compatibility,411+ // as addHelpCommand was originally used like helpCommand is now.412+ if (typeof helpCommand !== 'object') {413+ this.helpCommand(helpCommand, deprecatedDescription);414+ return this;415+ }416 400- _hasImplicitHelpCommand() {401- if (this._addImplicitHelpCommand === undefined) {402- return this.commands.length && !this._actionHandler && !this._findCommand('help');417+ this._addImplicitHelpCommand = true;418+ this._helpCommand = helpCommand;419+ return this;420+ }421+422+ /**423+ * Lazy create help command.424+ *425+ * @return {(Command|null)}426+ * @package427+ */428+ _getHelpCommand() {429+ const hasImplicitHelpCommand = this._addImplicitHelpCommand ??430+ (this.commands.length && !this._actionHandler && !this._findCommand('help'));431+432+ if (hasImplicitHelpCommand) {433+ if (this._helpCommand === undefined) {434+ this.helpCommand(undefined, undefined); // use default name and description435+ }436+ return this._helpCommand;437 }404- return this._addImplicitHelpCommand;438+ return null;439 }440 441 /**442 * Add hook for life cycle event.905 unmodified lines1348 1349 if (operands && this._findCommand(operands[0])) {1350 return this._dispatchSubcommand(operands[0], operands.slice(1), unknown);1351 }1318- if (this._hasImplicitHelpCommand() && operands[0] === this._helpCommandName) {1352+ if (this._getHelpCommand() && operands[0] === this._getHelpCommand().name()) {1353 return this._dispatchHelpCommand(operands[1]);1354 }1355 if (this._defaultCommandName) {1356 this._outputHelpIfRequested(unknown); // Run the help for default command from parent rather than passing to default command248 unmodified lines1605 if (this._findCommand(arg)) {1606 operands.push(arg);1607 if (args.length > 0) unknown.push(...args);1608 break;1575- } else if (arg === this._helpCommandName && this._hasImplicitHelpCommand()) {1609+ } else if (this._getHelpCommand() && arg === this._getHelpCommand().name()) {1610 operands.push(arg);1611 if (args.length > 0) operands.push(...args);1612 break;1613 } else if (this._defaultCommandName) {658 unmodified linesmodified:lib/help.js+2 added-7 removed
24 unmodified lines25 */26 27 visibleCommands(cmd) {28 const visibleCommands = cmd.commands.filter(cmd => !cmd._hidden);29- if (cmd._hasImplicitHelpCommand()) {30- // Create a command matching the implicit help command.31- const [, helpName, helpArgs] = cmd._helpCommandnameAndArgs.match(/([^ ]+) *(.*)/);32- const helpCommand = cmd.createCommand(helpName)33- .helpOption(false);34- helpCommand.description(cmd._helpCommandDescription);35- if (helpArgs) helpCommand.arguments(helpArgs);29+ const helpCommand = cmd._getHelpCommand();30+ if (helpCommand && !helpCommand._hidden) {31 visibleCommands.push(helpCommand);32 }33 if (this.sortSubcommands) {34 visibleCommands.sort((a, b) => {423 unmodified linesmodified:tests/command.chain.test.js+44 added-2 removed
32 unmodified lines33 const result = program.arguments('<file>');34 expect(result).toBe(program);35 });36 37- test('when call .addHelpCommand() then returns this', () => {37+ test('when call .addHelpCommand(cmd) then returns this', () => {38 const program = new Command();39- const result = program.addHelpCommand(false);39+ const result = program.addHelpCommand(new Command('assist'));40 expect(result).toBe(program);41 });42 43+ test('when call deprecated .addHelpCommand() then returns this', () => {44+ const program = new Command();45+ const result = program.addHelpCommand();46+ expect(result).toBe(program);47+ });48+49+ test('when call deprecated .addHelpCommand(boolean) then returns this', () => {50+ const program = new Command();51+ const result1 = program.addHelpCommand(true);52+ expect(result1).toBe(program);53+ const result2 = program.addHelpCommand(false);54+ expect(result2).toBe(program);55+ });56+57+ test('when call deprecated .addHelpCommand(string[, string]) then returns this', () => {58+ const program = new Command();59+ const result1 = program.addHelpCommand('assist');60+ expect(result1).toBe(program);61+ const result2 = program.addHelpCommand('assist', 'assist description');62+ expect(result2).toBe(program);63+ });64+65+ test('when call .helpCommand(name) then returns this', () => {66+ const program = new Command();67+ const result = program.helpCommand();68+ expect(result).toBe(program);69+ });70+71+ test('when call .helpCommand(name, description) then returns this', () => {72+ const program = new Command();73+ const result1 = program.helpCommand('assist', 'assist description');74+ expect(result1).toBe(program);75+ });76+77+ test('when call .helpCommand(boolean) then returns this', () => {78+ const program = new Command();79+ const result1 = program.helpCommand(true);80+ expect(result1).toBe(program);81+ const result2 = program.helpCommand(false);82+ expect(result2).toBe(program);83+ });84+85 test('when call .exitOverride() then returns this', () => {86 const program = new Command();87 const result = program.exitOverride(() => { });88 expect(result).toBe(program);165 unmodified linesmodified:tests/command.copySettings.test.js+18 added-5 removed
48 unmodified lines4950515253535455565757585960615960616263646566676869707172737475767778798066 unmodified lines48 unmodified lines expect(cmd._helpShortFlag).toBe('-Z'); expect(cmd._helpLongFlag).toBe('--zz'); });
test('when copyInheritedSettings then copies addHelpCommand(name, description)', () => { test('when copyInheritedSettings then copies custom help command', () => { const source = new commander.Command(); const cmd = new commander.Command();
source.addHelpCommand('HELP [cmd]', 'ddd'); source.helpCommand('HELP [cmd]', 'ddd'); cmd.copyInheritedSettings(source); expect(cmd._helpCommandName).toBe('HELP'); expect(cmd._helpCommandnameAndArgs).toBe('HELP [cmd]'); expect(cmd._helpCommandDescription).toBe('ddd'); cmd.helpCommand(true); // force enable const helpCommand = cmd._getHelpCommand(); expect(helpCommand).toBeTruthy(); expect(helpCommand.name()).toBe('HELP'); expect(helpCommand.description()).toBe('ddd'); });
test('when copyInheritedSettings then does not copy help enable override', () => { const source = new commander.Command(); const cmd = new commander.Command();
// Existing behaviour, force enable/disable does not inherit, // largely so (probably redundant) program.helpCommand(true) does not inherit to leaf subcommands. source.helpCommand(true); cmd.copyInheritedSettings(source); expect(cmd._addHelpOption).toBeUndefined(); });
test('when copyInheritedSettings then copies configureHelp(config)', () => { const source = new commander.Command(); const cmd = new commander.Command();
66 unmodified linesmodified:typings/index.d.ts+17 added-8 removed
417 unmodified lines418 */419 arguments(names: string): this;420 421 /**422- * Override default decision whether to add implicit help command.422+ * Customise or override default help command. By default a help command is automatically added if your command has subcommands.423 *424 * @example425+ * ```ts426+ * program.helpCommand('help [cmd]');427+ * program.helpCommand('help [cmd]', 'show help');428+ * program.helpCommand(false); // suppress default help command429+ * program.helpCommand(true); // add help command even if no subcommands430 * ```426- * addHelpCommand() // force on427- * addHelpCommand(false); // force off428- * addHelpCommand('help [cmd]', 'display help for [cmd]'); // force on with custom details429- * ```430- *431- * @returns `this` command for chaining431 */433- addHelpCommand(enableOrNameAndArgs?: string | boolean, description?: string): this;432+ helpCommand(nameAndArgs: string, description?: string): this;433+ helpCommand(enable: boolean): this;434 435 /**436+ * Add prepared custom help command.437+ */438+ addHelpCommand(cmd: Command): this;439+ /** @deprecated since v12, instead use helpCommand */440+ addHelpCommand(nameAndArgs: string, description?: string): this;441+ /** @deprecated since v12, instead use helpCommand */442+ addHelpCommand(enable?: boolean): this;443+444+ /**445 * Add hook for life cycle event.446 */447 hook(event: HookEvent, listener: (thisCommand: Command, actionCommand: Command) => void | Promise<void>): this;448 445 unmodified linesmodified:typings/index.test-d.ts+10 added-2 removed
57 unmodified lines58 // arguments59 expectType<commander.Command>(program.arguments('<cmd> [env]'));60 61 // addHelpCommand62+expectType<commander.Command>(program.addHelpCommand(new commander.Command('assist')));63+// Deprecated uses64 expectType<commander.Command>(program.addHelpCommand());65 expectType<commander.Command>(program.addHelpCommand(false));66 expectType<commander.Command>(program.addHelpCommand(true));65-expectType<commander.Command>(program.addHelpCommand('compress <file>'));66-expectType<commander.Command>(program.addHelpCommand('compress <file>', 'compress target file'));67+expectType<commander.Command>(program.addHelpCommand('assist [cmd]'));68+expectType<commander.Command>(program.addHelpCommand('assist [file]', 'display help'));69 70+// helpCommand71+expectType<commander.Command>(program.helpCommand(false));72+expectType<commander.Command>(program.helpCommand(true));73+expectType<commander.Command>(program.helpCommand('assist [cmd]'));74+expectType<commander.Command>(program.helpCommand('assist [file]', 'display help'));75+76 // exitOverride77 expectType<commander.Command>(program.exitOverride());78 expectType<commander.Command>(program.exitOverride((err): never => {79 return process.exit(err.exitCode);431 unmodified linesmodified:package-lock.json+113 added-85 removed
723 unmodified lines724 "node": "^12.0.0 || ^14.0.0 || >=16.0.0"725 }726 },727 "node_modules/@eslint/eslintrc": {728- "version": "2.1.2",729- "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz",730- "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==",728+ "version": "2.1.3",729+ "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.3.tgz",730+ "integrity": "sha512-yZzuIG+jnVu6hNSzFEN07e8BxF3uAzYtQb6uDkaYZLo6oYZDCq454c5kB8zxnzfCYyP4MIuyBn10L0DqwujTmA==",731 "dev": true,732 "dependencies": {733 "ajv": "^6.12.4",734 "debug": "^4.3.2",12 unmodified lines747 "url": "https://opencollective.com/eslint"748 }749 },750 "node_modules/@eslint/js": {751- "version": "8.52.0",752- "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz",753- "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==",751+ "version": "8.53.0",752+ "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.53.0.tgz",753+ "integrity": "sha512-Kn7K8dx/5U6+cT1yEhpX1w4PCSg0M+XyRILPgvwcEBjerFWCwQj5sbr3/VmxqV0JGHCBCzyd6LxypEuehypY1w==",754 "dev": true,755 "engines": {756 "node": "^12.22.0 || ^14.17.0 || >=16.0.0"757 }623 unmodified lines1381 "@types/istanbul-lib-report": "*"1382 }1383 },1384 "node_modules/@types/jest": {1385- "version": "29.5.6",1386- "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.6.tgz",1387- "integrity": "sha512-/t9NnzkOpXb4Nfvg17ieHE6EeSjDS2SGSpNYfoLbUAeL/EOueU/RSdOWFpfQTXBEM7BguYW1XQ0EbM+6RlIh6w==",1385+ "version": "29.5.8",1386+ "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.8.tgz",1387+ "integrity": "sha512-fXEFTxMV2Co8ZF5aYFJv+YeA08RTYJfhtN5c9JSv/mFEMe+xxjufCb+PHL+bJcMs/ebPUsBu+UNTEz+ydXrR6g==",1388 "dev": true,1389 "dependencies": {1390 "expect": "^29.0.0",1391 "pretty-format": "^29.0.0"17 unmodified lines1409 "integrity": "sha512-ZYFzrvyWUNhaPomn80dsMNgMeXxNWZBdkuG/hWlUvXvbdUH8ZERNBGXnU87McuGcWDsyzX2aChCv/SVN348k3A==",1410 "dev": true1411 },1412 "node_modules/@types/node": {1413- "version": "20.8.9",1414- "resolved": "https://registry.npmjs.org/@types/node/-/node-20.8.9.tgz",1415- "integrity": "sha512-UzykFsT3FhHb1h7yD4CA4YhBHq545JC0YnEz41xkipN88eKQtL6rSgocL5tbAP6Ola9Izm/Aw4Ora8He4x0BHg==",1413+ "version": "20.9.0",1414+ "resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",1415+ "integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",1416 "dev": true,1417 "dependencies": {1418 "undici-types": "~5.26.4"1419 }31 unmodified lines1451 "integrity": "sha512-axdPBuLuEJt0c4yI5OZssC19K2Mq1uKdrfZBzuxLvaztgqUtFYZUNw7lETExPYJR9jdEoIg4mb7RQKRQzOkeGQ==",1452 "dev": true1453 },1454 "node_modules/@typescript-eslint/eslint-plugin": {1455- "version": "6.9.0",1456- "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.9.0.tgz",1457- "integrity": "sha512-lgX7F0azQwRPB7t7WAyeHWVfW1YJ9NIgd9mvGhfQpRY56X6AVf8mwM8Wol+0z4liE7XX3QOt8MN1rUKCfSjRIA==",1455+ "version": "6.10.0",1456+ "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.10.0.tgz",1457+ "integrity": "sha512-uoLj4g2OTL8rfUQVx2AFO1hp/zja1wABJq77P6IclQs6I/m9GLrm7jCdgzZkvWdDCQf1uEvoa8s8CupsgWQgVg==",1458 "dev": true,1459 "dependencies": {1460 "@eslint-community/regexpp": "^4.5.1",1461- "@typescript-eslint/scope-manager": "6.9.0",1462- "@typescript-eslint/type-utils": "6.9.0",1463- "@typescript-eslint/utils": "6.9.0",1464- "@typescript-eslint/visitor-keys": "6.9.0",1461+ "@typescript-eslint/scope-manager": "6.10.0",1462+ "@typescript-eslint/type-utils": "6.10.0",1463+ "@typescript-eslint/utils": "6.10.0",1464+ "@typescript-eslint/visitor-keys": "6.10.0",1465 "debug": "^4.3.4",1466 "graphemer": "^1.4.0",1467 "ignore": "^5.2.4",1468 "natural-compare": "^1.4.0",17 unmodified lines1486 }1487 }1488 },1489 "node_modules/@typescript-eslint/parser": {1490- "version": "6.9.0",1491- "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.9.0.tgz",1492- "integrity": "sha512-GZmjMh4AJ/5gaH4XF2eXA8tMnHWP+Pm1mjQR2QN4Iz+j/zO04b9TOvJYOX2sCNIQHtRStKTxRY1FX7LhpJT4Gw==",1490+ "version": "6.10.0",1491+ "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.10.0.tgz",1492+ "integrity": "sha512-+sZwIj+s+io9ozSxIWbNB5873OSdfeBEH/FR0re14WLI6BaKuSOnnwCJ2foUiu8uXf4dRp1UqHP0vrZ1zXGrog==",1493 "dev": true,1494 "dependencies": {1495- "@typescript-eslint/scope-manager": "6.9.0",1496- "@typescript-eslint/types": "6.9.0",1497- "@typescript-eslint/typescript-estree": "6.9.0",1498- "@typescript-eslint/visitor-keys": "6.9.0",1495+ "@typescript-eslint/scope-manager": "6.10.0",1496+ "@typescript-eslint/types": "6.10.0",1497+ "@typescript-eslint/typescript-estree": "6.10.0",1498+ "@typescript-eslint/visitor-keys": "6.10.0",1499 "debug": "^4.3.4"1500 },1501 "engines": {1502 "node": "^16.0.0 || >=18.0.0"11 unmodified lines1514 }1515 }1516 },1517 "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/scope-manager": {1518- "version": "6.9.0",1519- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz",1520- "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==",1518+ "version": "6.10.0",1519+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.10.0.tgz",1520+ "integrity": "sha512-TN/plV7dzqqC2iPNf1KrxozDgZs53Gfgg5ZHyw8erd6jd5Ta/JIEcdCheXFt9b1NYb93a1wmIIVW/2gLkombDg==",1521 "dev": true,1522 "dependencies": {1523- "@typescript-eslint/types": "6.9.0",1524- "@typescript-eslint/visitor-keys": "6.9.0"1523+ "@typescript-eslint/types": "6.10.0",1524+ "@typescript-eslint/visitor-keys": "6.10.0"1525 },1526 "engines": {1527 "node": "^16.0.0 || >=18.0.0"1528 },2 unmodified lines1531 "url": "https://opencollective.com/typescript-eslint"1532 }1533 },1534 "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/types": {1535- "version": "6.9.0",1536- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz",1537- "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==",1535+ "version": "6.10.0",1536+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.10.0.tgz",1537+ "integrity": "sha512-36Fq1PWh9dusgo3vH7qmQAj5/AZqARky1Wi6WpINxB6SkQdY5vQoT2/7rW7uBIsPDcvvGCLi4r10p0OJ7ITAeg==",1538 "dev": true,1539 "engines": {1540 "node": "^16.0.0 || >=18.0.0"1541 },2 unmodified lines1544 "url": "https://opencollective.com/typescript-eslint"1545 }1546 },1547 "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/typescript-estree": {1548- "version": "6.9.0",1549- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz",1550- "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==",1548+ "version": "6.10.0",1549+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.10.0.tgz",1550+ "integrity": "sha512-ek0Eyuy6P15LJVeghbWhSrBCj/vJpPXXR+EpaRZqou7achUWL8IdYnMSC5WHAeTWswYQuP2hAZgij/bC9fanBg==",1551 "dev": true,1552 "dependencies": {1553- "@typescript-eslint/types": "6.9.0",1554- "@typescript-eslint/visitor-keys": "6.9.0",1553+ "@typescript-eslint/types": "6.10.0",1554+ "@typescript-eslint/visitor-keys": "6.10.0",1555 "debug": "^4.3.4",1556 "globby": "^11.1.0",1557 "is-glob": "^4.0.3",1558 "semver": "^7.5.4",12 unmodified lines1571 }1572 }1573 },1574 "node_modules/@typescript-eslint/parser/node_modules/@typescript-eslint/visitor-keys": {1575- "version": "6.9.0",1576- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz",1577- "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==",1575+ "version": "6.10.0",1576+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.10.0.tgz",1577+ "integrity": "sha512-xMGluxQIEtOM7bqFCo+rCMh5fqI+ZxV5RUUOa29iVPz1OgCZrtc7rFnz5cLUazlkPKYqX+75iuDq7m0HQ48nCg==",1578 "dev": true,1579 "dependencies": {1580- "@typescript-eslint/types": "6.9.0",1580+ "@typescript-eslint/types": "6.10.0",1581 "eslint-visitor-keys": "^3.4.1"1582 },1583 "engines": {1584 "node": "^16.0.0 || >=18.0.0"3 unmodified lines1588 "url": "https://opencollective.com/typescript-eslint"1589 }1590 },1591 "node_modules/@typescript-eslint/scope-manager": {1592- "version": "6.9.0",1593- "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.9.0.tgz",1594- "integrity": "sha512-1R8A9Mc39n4pCCz9o79qRO31HGNDvC7UhPhv26TovDsWPBDx+Sg3rOZdCELIA3ZmNoWAuxaMOT7aWtGRSYkQxw==",1592+ "version": "6.10.0",1593+ "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.10.0.tgz",1594+ "integrity": "sha512-TN/plV7dzqqC2iPNf1KrxozDgZs53Gfgg5ZHyw8erd6jd5Ta/JIEcdCheXFt9b1NYb93a1wmIIVW/2gLkombDg==",1595 "dev": true,1596 "dependencies": {1597- "@typescript-eslint/types": "6.9.0",1598- "@typescript-eslint/visitor-keys": "6.9.0"1597+ "@typescript-eslint/types": "6.10.0",1598+ "@typescript-eslint/visitor-keys": "6.10.0"1599 },1600 "engines": {1601 "node": "^16.0.0 || >=18.0.0"1602 },2 unmodified lines1605 "url": "https://opencollective.com/typescript-eslint"1606 }1607 },1608 "node_modules/@typescript-eslint/type-utils": {1609- "version": "6.9.0",1610- "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.9.0.tgz",1611- "integrity": "sha512-XXeahmfbpuhVbhSOROIzJ+b13krFmgtc4GlEuu1WBT+RpyGPIA4Y/eGnXzjbDj5gZLzpAXO/sj+IF/x2GtTMjQ==",1609+ "version": "6.10.0",1610+ "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.10.0.tgz",1611+ "integrity": "sha512-wYpPs3hgTFblMYwbYWPT3eZtaDOjbLyIYuqpwuLBBqhLiuvJ+9sEp2gNRJEtR5N/c9G1uTtQQL5AhV0fEPJYcg==",1612 "dev": true,1613 "dependencies": {1614- "@typescript-eslint/typescript-estree": "6.9.0",1615- "@typescript-eslint/utils": "6.9.0",1614+ "@typescript-eslint/typescript-estree": "6.10.0",1615+ "@typescript-eslint/utils": "6.10.0",1616 "debug": "^4.3.4",1617 "ts-api-utils": "^1.0.1"1618 },1619 "engines": {12 unmodified lines1632 }1633 }1634 },1635 "node_modules/@typescript-eslint/types": {1636- "version": "6.9.0",1637- "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.9.0.tgz",1638- "integrity": "sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==",1636+ "version": "6.10.0",1637+ "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.10.0.tgz",1638+ "integrity": "sha512-36Fq1PWh9dusgo3vH7qmQAj5/AZqARky1Wi6WpINxB6SkQdY5vQoT2/7rW7uBIsPDcvvGCLi4r10p0OJ7ITAeg==",1639 "dev": true,1640 "engines": {1641 "node": "^16.0.0 || >=18.0.0"1642 },2 unmodified lines1645 "url": "https://opencollective.com/typescript-eslint"1646 }1647 },1648 "node_modules/@typescript-eslint/typescript-estree": {1649- "version": "6.9.0",1650- "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.9.0.tgz",1651- "integrity": "sha512-NJM2BnJFZBEAbCfBP00zONKXvMqihZCrmwCaik0UhLr0vAgb6oguXxLX1k00oQyD+vZZ+CJn3kocvv2yxm4awQ==",1649+ "version": "6.10.0",1650+ "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.10.0.tgz",1651+ "integrity": "sha512-ek0Eyuy6P15LJVeghbWhSrBCj/vJpPXXR+EpaRZqou7achUWL8IdYnMSC5WHAeTWswYQuP2hAZgij/bC9fanBg==",1652 "dev": true,1653 "dependencies": {1654- "@typescript-eslint/types": "6.9.0",1655- "@typescript-eslint/visitor-keys": "6.9.0",1654+ "@typescript-eslint/types": "6.10.0",1655+ "@typescript-eslint/visitor-keys": "6.10.0",1656 "debug": "^4.3.4",1657 "globby": "^11.1.0",1658 "is-glob": "^4.0.3",1659 "semver": "^7.5.4",12 unmodified lines1672 }1673 }1674 },1675 "node_modules/@typescript-eslint/utils": {1676- "version": "6.9.0",1677- "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.9.0.tgz",1678- "integrity": "sha512-5Wf+Jsqya7WcCO8me504FBigeQKVLAMPmUzYgDbWchINNh1KJbxCgVya3EQ2MjvJMVeXl3pofRmprqX6mfQkjQ==",1676+ "version": "6.10.0",1677+ "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.10.0.tgz",1678+ "integrity": "sha512-v+pJ1/RcVyRc0o4wAGux9x42RHmAjIGzPRo538Z8M1tVx6HOnoQBCX/NoadHQlZeC+QO2yr4nNSFWOoraZCAyg==",1679 "dev": true,1680 "dependencies": {1681 "@eslint-community/eslint-utils": "^4.4.0",1682 "@types/json-schema": "^7.0.12",1683 "@types/semver": "^7.5.0",1684- "@typescript-eslint/scope-manager": "6.9.0",1685- "@typescript-eslint/types": "6.9.0",1686- "@typescript-eslint/typescript-estree": "6.9.0",1684+ "@typescript-eslint/scope-manager": "6.10.0",1685+ "@typescript-eslint/types": "6.10.0",1686+ "@typescript-eslint/typescript-estree": "6.10.0",1687 "semver": "^7.5.4"1688 },1689 "engines": {1690 "node": "^16.0.0 || >=18.0.0"6 unmodified lines1697 "eslint": "^7.0.0 || ^8.0.0"1698 }1699 },1700 "node_modules/@typescript-eslint/visitor-keys": {1701- "version": "6.9.0",1702- "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.9.0.tgz",1703- "integrity": "sha512-dGtAfqjV6RFOtIP8I0B4ZTBRrlTT8NHHlZZSchQx3qReaoDeXhYM++M4So2AgFK9ZB0emRPA6JI1HkafzA2Ibg==",1701+ "version": "6.10.0",1702+ "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.10.0.tgz",1703+ "integrity": "sha512-xMGluxQIEtOM7bqFCo+rCMh5fqI+ZxV5RUUOa29iVPz1OgCZrtc7rFnz5cLUazlkPKYqX+75iuDq7m0HQ48nCg==",1704 "dev": true,1705 "dependencies": {1706- "@typescript-eslint/types": "6.9.0",1706+ "@typescript-eslint/types": "6.10.0",1707 "eslint-visitor-keys": "^3.4.1"1708 },1709 "engines": {1710 "node": "^16.0.0 || >=18.0.0"9 unmodified lines1720 "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==",1721 "dev": true1722 },1723 "node_modules/acorn": {1724- "version": "8.10.0",1725- "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.10.0.tgz",1726- "integrity": "sha512-F0SAmZ8iUtS//m8DmCTA0jlh6TDKkHQyK6xc6V4KDTyZKA9dnvX9/3sRTVQrWm79glUAZbnmmNcdYwUIHWVybw==",1724+ "version": "8.11.2",1725+ "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",1726+ "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==",1727 "dev": true,1728 "bin": {1729 "acorn": "bin/acorn"1730 },436 unmodified lines2167 "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",2168 "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",2169 "dev": true2170 },2171+ "node_modules/builtin-modules": {2172+ "version": "3.3.0",2173+ "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz",2174+ "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==",2175+ "dev": true,2176+ "engines": {2177+ "node": ">=6"2178+ },2179+ "funding": {2180+ "url": "https://github.com/sponsors/sindresorhus"2181+ }2182+ },2183 "node_modules/builtins": {2184 "version": "5.0.1",2185 "resolved": "https://registry.npmjs.org/builtins/-/builtins-5.0.1.tgz",2186 "integrity": "sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==",511 unmodified lines2698 "url": "https://github.com/sponsors/sindresorhus"2699 }2700 },2701 "node_modules/eslint": {2690- "version": "8.52.0",2691- "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz",2692- "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==",2702+ "version": "8.53.0",2703+ "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.53.0.tgz",2704+ "integrity": "sha512-N4VuiPjXDUa4xVeV/GC/RV3hQW9Nw+Y463lkWaKKXKYMvmRiRDAtfpuPFLN+E1/6ZhyR8J2ig+eVREnYgUsiag==",2705 "dev": true,2706 "dependencies": {2707 "@eslint-community/eslint-utils": "^4.2.0",2708 "@eslint-community/regexpp": "^4.6.1",2697- "@eslint/eslintrc": "^2.1.2",2698- "@eslint/js": "8.52.0",2709+ "@eslint/eslintrc": "^2.1.3",2710+ "@eslint/js": "8.53.0",2711 "@humanwhocodes/config-array": "^0.11.13",2712 "@humanwhocodes/module-importer": "^1.0.1",2713 "@nodelib/fs.walk": "^1.2.8",2714 "@ungap/structured-clone": "^1.2.0",380 unmodified lines3095 "node": ">=4.0"3096 }3097 },3098 "node_modules/eslint-plugin-n": {3087- "version": "16.2.0",3088- "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-16.2.0.tgz",3089- "integrity": "sha512-AQER2jEyQOt1LG6JkGJCCIFotzmlcCZFur2wdKrp1JX2cNotC7Ae0BcD/4lLv3lUAArM9uNS8z/fsvXTd0L71g==",3099+ "version": "16.3.1",3100+ "resolved": "https://registry.npmjs.org/eslint-plugin-n/-/eslint-plugin-n-16.3.1.tgz",3101+ "integrity": "sha512-w46eDIkxQ2FaTHcey7G40eD+FhTXOdKudDXPUO2n9WNcslze/i/HT2qJ3GXjHngYSGDISIgPNhwGtgoix4zeOw==",3102 "dev": true,3103 "dependencies": {3104 "@eslint-community/eslint-utils": "^4.4.0",3105 "builtins": "^5.0.1",3106 "eslint-plugin-es-x": "^7.1.0",3107 "get-tsconfig": "^4.7.0",3108 "ignore": "^5.2.4",3109+ "is-builtin-module": "^3.2.1",3110 "is-core-module": "^2.12.1",3111 "minimatch": "^3.1.2",3112 "resolve": "^1.22.2",3113 "semver": "^7.5.3"843 unmodified lines3957 "funding": {3958 "url": "https://github.com/sponsors/ljharb"3959 }3960 },3961+ "node_modules/is-builtin-module": {3962+ "version": "3.2.1",3963+ "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz",3964+ "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==",3965+ "dev": true,3966+ "dependencies": {3967+ "builtin-modules": "^3.3.0"3968+ },3969+ "engines": {3970+ "node": ">=6"3971+ },3972+ "funding": {3973+ "url": "https://github.com/sponsors/sindresorhus"3974+ }3975+ },3976 "node_modules/is-callable": {3977 "version": "1.2.7",3978 "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz",3979 "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==",1658 unmodified lines5638 "node": ">= 6"5639 }5640 },5641 "node_modules/punycode": {5614- "version": "2.3.0",5615- "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz",5616- "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==",5642+ "version": "2.3.1",5643+ "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",5644+ "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",5645 "dev": true,5646 "engines": {5647 "node": ">=6"5648 }1241 unmodified linesmodified:Readme.md+6 added-4 removed
35 unmodified lines36 - [.name](#name)37 - [.usage](#usage)38 - [.description and .summary](#description-and-summary)39 - [.helpOption(flags, description)](#helpoptionflags-description)40- - [.addHelpCommand()](#addhelpcommand)40+ - [.helpCommand()](#helpcommand)41 - [More configuration](#more-configuration-2)42 - [Custom event listeners](#custom-event-listeners)43 - [Bits and pieces](#bits-and-pieces)44 - [.parse() and .parseAsync()](#parse-and-parseasync)858 unmodified lines903 program904 .helpOption('-e, --HELP', 'read more information');905 ```906 907-### .addHelpCommand()907+### .helpCommand()908 909-A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.addHelpCommand()` and `.addHelpCommand(false)`.909+A help command is added by default if your command has subcommands. You can explicitly turn on or off the implicit help command with `.helpCommand(true)` and `.helpCommand(false)`.910 911 You can both turn on and customise the help command by supplying the name and description:912 913 ```js914-program.addHelpCommand('assist [command]', 'show assistance');914+program.helpCommand('assist [command]', 'show assistance');915 ```916 917+(Or use `.addHelpCommand()` to add a command you construct yourself.)918+919 ### More configuration920 921 The built-in help is formatted using the Help class.922 You can configure the Help behaviour by modifying data properties and methods using `.configureHelp()`, or by subclassing using `.createHelp()` if you prefer.230 unmodified lines