Skip to content
Myr

Add Removed section to Deprecated (#2078)

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 9821f3a · Browse files · 1 file+48 added−45 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+48 added−45 removed

  • other:+48 added−45 removed

1 file+48 added−45 removed

modified:docs/deprecated.md+48 added-45 removed
2 unmodified lines
3These features are deprecated, which means they may go away in a future major version of Commander.4They are currently still available for backwards compatibility, but should not be used in new code.56- [Deprecated](#deprecated)7 - [RegExp .option() parameter](#regexp-option-parameter)8 - [noHelp](#nohelp)9 - [Default import of global Command object](#default-import-of-global-command-object)10 - [Callback to .help() and .outputHelp()](#callback-to-help-and-outputhelp)11 - [.on('--help')](#on--help)12 - [.on('command:\*')](#oncommand)13 - [.command('\*')](#command)14 - [cmd.description(cmdDescription, argDescriptions)](#cmddescriptioncmddescription-argdescriptions)15 - [InvalidOptionArgumentError](#invalidoptionargumenterror)16 - [Short option flag longer than a single character](#short-option-flag-longer-than-a-single-character)17 - [Import from `commander/esm.mjs`](#import-from-commanderesmmjs)18 - [cmd.\_args](#cmd_args)7 - [RegExp .option() parameter](#regexp-option-parameter)8 - [noHelp](#nohelp)9 - [Callback to .help() and .outputHelp()](#callback-to-help-and-outputhelp)10 - [.on('--help')](#on--help)11 - [.on('command:\*')](#oncommand)12 - [.command('\*')](#command)13 - [cmd.description(cmdDescription, argDescriptions)](#cmddescriptioncmddescription-argdescriptions)14 - [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 - [Removed](#removed)19 - [Default import of global Command object](#default-import-of-global-command-object)2020## RegExp .option() parameter21### RegExp .option() parameter2223The `.option()` method allowed a RegExp as the third parameter to restrict what values were accepted.2425```js
3 unmodified lines
29Removed from README in Commander v3. Deprecated from Commander v7.3031The newer functionality is the Option `.choices()` method, or using a custom option processing function.3232## noHelp33### noHelp3435This was an option passed to `.command()` to hide the command from the built-in help:3637```js
1 unmodified line
39```4041The option was renamed `hidden` in Commander v5.1. Deprecated from Commander v7.4242## Default import of global Command object43### Callback to .help() and .outputHelp()4444The default import was a global Command object.4546```js47const program = require('commander');48```4950The global Command object is exported as `program` from Commander v5, or import the Command object.5152```js53const { program } = require('commander');54// or55const { Command } = require('commander');56const program = new Command()57```5859- Removed from README in Commander v5.60- Deprecated from Commander v7.61- Removed from TypeScript declarations in Commander v8.62- Removed from CommonJS in Commander v12. Deprecated and gone!6364## Callback to .help() and .outputHelp()6545These routines allowed a callback parameter to process the built-in help before display.4647```js48program.outputHelp((text) => {
8 unmodified lines
57```5859Deprecated from Commander v7.6082## .on('--help')61### .on('--help')6263This was the way to add custom help after the built-in help. From Commander v3.0.0 this used the custom long help option flags, if changed.6465```js
16 unmodified lines
82```8384Deprecated from Commander v7.85107## .on('command:*')86### .on('command:*')8788This was emitted when the command argument did not match a known subcommand (as part of the implementation of `.command('*')`).8990One use was for adding an error for an unknown subcommand. An error is now the default built-in behaviour.
2 unmodified lines
93or for custom behaviour catch the `commander.unknownCommand` error.9495Deprecated from Commander v8.3.96118## .command('*')97### .command('*')9899This was used to add a default command to the program.100101```js
11 unmodified lines
113```114115Removed from README in Commander v5. Deprecated from Commander v8.3.116138## cmd.description(cmdDescription, argDescriptions)117### cmd.description(cmdDescription, argDescriptions)118119This was used to add command argument descriptions for the help.120121```js
14 unmodified lines
136```137138Deprecated from Commander v8.139161## InvalidOptionArgumentError140### InvalidOptionArgumentError141142This was used for throwing an error from custom option processing, for a nice error message.143144```js
21 unmodified lines
166```167168Deprecated from Commander v8.169191## Short option flag longer than a single character170### Short option flag longer than a single character171172Short option flags like `-ws` were never supported, but the old README did not make this clear. The README now states that short options are a single character.173174README updated in Commander v3. Deprecated from Commander v9.175197## Import from `commander/esm.mjs`176### Import from `commander/esm.mjs`177178The first support for named imports required an explicit entry file.179180```js
7 unmodified lines
188```189190README updated in Commander v9. Deprecated from Commander v9.191213## cmd._args192### cmd._args193194This was always private, but was previously the only way to access the command `Argument` array.195196```js
6 unmodified lines
203const registeredArguments = program.registeredArguments;204```205206Deprecated from Commander v11.207208## Removed209210### Default import of global Command object211212The default import was a global Command object.213214```js215const program = require('commander');216```217218The global Command object is exported as `program` from Commander v5, or import the Command object.219220```js221const { program } = require('commander');222// or223const { Command } = require('commander');224const program = new Command()225```226227- Removed from README in Commander v5.228- Deprecated from Commander v7.229- Removed from TypeScript declarations in Commander v8.230- Removed from CommonJS in Commander v12. Deprecated and gone!