Skip to content
Myr

Deprecated functionality (#1349)

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

* Add documentation on deprecated routines * Tidy up deprecated and link from README.

authored by John Gee · committed by GitHub · parent 9abb793 · Browse files · 4 files+99 added−2 removed
This commit

State

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

Diff stats

4 files+99 added−2 removed

  • other:+99 added−2 removed

4 files+99 added−2 removed

added:docs/deprecated.md+88 added
1# Deprecated23These 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## RegExp .option() parameter78The `.option()` method allowed a RegExp as the third parameter to restrict what values were accepted.910```js11program.option('-c,--coffee <type>', 'coffee', /short-white|long-black/);12```1314Removed from README in Commander v3. Deprecated from Commander v7.1516The newer functionality is the Option `.choices()' method, or using a custom option processing function.1718## noHelp1920This was an option passed to `.command()` to hide the command from the built-in help:2122```js23program.command('example', 'examnple command', { noHelp: true });24```2526The option was renamed `hidden` in Commander v5.1. Deprecated from Commander v7. 2728## Default import of global Command object2930The default import was a global Command object.3132```js33const program = require('commander');34```3536The global Command object is exported as `program` from Commander v5, or import the Command object.3738```js39const { program } = require('commander');40// or41const { Command } = require('commander');42comnst program = new Command()43```4445Removed from README in Commander v5. Deprecated from Commander v7. 4647## Callback to .help() and .outputHelp()4849These routines allowed a callback parameter to process the built-in help before display.5051```js52program.outputHelp((text) => {53 return colors.red(text);54});55```5657The newer approach is to directly access the built-in help text using `.helpInformation()`.5859```js60console.error(colors.red(program.helpInformation()));61```6263Deprecated from Commander v7.6465## .on('--help')6667This 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.6869```js70program.on('--help', function() {71 console.log('')72 console.log('Examples:');73 console.log(' $ custom-help --help');74 console.log(' $ custom-help -h');75});76```7778The replacement is `.addHelpText()`:7980```js81program.addHelpText('after', `82Examples:83 $ custom-help --help84 $ custom-help -h`85);86```8788Deprecated from Commander v7.
modified:typings/index.d.ts+2 added-1 removed
445 unmodified lines
446 }447 type CommandConstructor = new (name?: string) => Command;448449 interface CommandOptions {450 noHelp?: boolean; // old name for hidden450 hidden?: boolean;451 isDefault?: boolean;452 /** @deprecated since v7, replaced by hidden */453 noHelp?: boolean;454 }455 interface ExecutableCommandOptions extends CommandOptions {456 executableFile?: string;457 }
19 unmodified lines
modified:index.js+1 added-1 removed
298 unmodified lines
299 cmd._executableHandler = true;300 }301 if (opts.isDefault) this._defaultCommandName = cmd._name;302303 cmd._hidden = !!(opts.noHelp || opts.hidden);303 cmd._hidden = !!(opts.noHelp || opts.hidden); // noHelp is deprecated old name for hidden304 cmd._hasHelpOption = this._hasHelpOption;305 cmd._helpFlags = this._helpFlags;306 cmd._helpDescription = this._helpDescription;307 cmd._helpShortFlag = this._helpShortFlag;
1766 unmodified lines
modified:Readme.md+8 added
41 unmodified lines
42 - [Import into ECMAScript Module](#import-into-ecmascript-module)43 - [Node options such as `--harmony`](#node-options-such-as---harmony)44 - [Debugging stand-alone executable subcommands](#debugging-stand-alone-executable-subcommands)45 - [Override exit handling](#override-exit-handling)46 - [Additional documentation](#additional-documentation)47 - [Examples](#examples)48 - [Support](#support)49 - [Commander for enterprise](#commander-for-enterprise)50
711 unmodified lines
762 // custom processing...763}764```765766### Additional documentation767768There is more information available about:769770- [deprecated](./docs/deprecated.md) features still supported for backwards compatibility771- [options taking varying arguments](./docs/options-taking-varying-arguments.md)772773## Examples774775Example file: [deploy](./examples/deploy)776
49 unmodified lines