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
Provenance
- Commit
9f5aabc- Tree
0555540- Author
John Gee <john@ruru.gen.nz>- Committer
GitHub <noreply@github.com>- Parent
9abb793
4 files changed+99 added−2 removed
added:docs/deprecated.md+88 added
1+# Deprecated2+3+These features are deprecated, which means they may go away in a future major version of Commander.4+They are currently still available for backwards compatibility, but should not be used in new code.5+6+## RegExp .option() parameter7+8+The `.option()` method allowed a RegExp as the third parameter to restrict what values were accepted.9+10+```js11+program.option('-c,--coffee <type>', 'coffee', /short-white|long-black/);12+```13+14+Removed from README in Commander v3. Deprecated from Commander v7.15+16+The newer functionality is the Option `.choices()' method, or using a custom option processing function.17+18+## noHelp19+20+This was an option passed to `.command()` to hide the command from the built-in help:21+22+```js23+program.command('example', 'examnple command', { noHelp: true });24+```25+26+The option was renamed `hidden` in Commander v5.1. Deprecated from Commander v7. 27+28+## Default import of global Command object29+30+The default import was a global Command object.31+32+```js33+const program = require('commander');34+```35+36+The global Command object is exported as `program` from Commander v5, or import the Command object.37+38+```js39+const { program } = require('commander');40+// or41+const { Command } = require('commander');42+comnst program = new Command()43+```44+45+Removed from README in Commander v5. Deprecated from Commander v7. 46+47+## Callback to .help() and .outputHelp()48+49+These routines allowed a callback parameter to process the built-in help before display.50+51+```js52+program.outputHelp((text) => {53+ return colors.red(text);54+});55+```56+57+The newer approach is to directly access the built-in help text using `.helpInformation()`.58+59+```js60+console.error(colors.red(program.helpInformation()));61+```62+63+Deprecated from Commander v7.64+65+## .on('--help')66+67+This 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.68+69+```js70+program.on('--help', function() {71+ console.log('')72+ console.log('Examples:');73+ console.log(' $ custom-help --help');74+ console.log(' $ custom-help -h');75+});76+```77+78+The replacement is `.addHelpText()`:79+80+```js81+program.addHelpText('after', `82+Examples:83+ $ custom-help --help84+ $ custom-help -h`85+);86+```87+88+Deprecated from Commander v7. modified:typings/index.d.ts+2 added-1 removed
445 unmodified lines446 }447 type CommandConstructor = new (name?: string) => Command;448 449 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 linesmodified:index.js+1 added-1 removed
298 unmodified lines299 cmd._executableHandler = true;300 }301 if (opts.isDefault) this._defaultCommandName = cmd._name;302 303- 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 linesmodified:Readme.md+8 added
41 unmodified lines42 - [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 lines762 // custom processing...763 }764 ```765 766+### Additional documentation767+768+There is more information available about:769+770+- [deprecated](./docs/deprecated.md) features still supported for backwards compatibility771+- [options taking varying arguments](./docs/options-taking-varying-arguments.md)772+773 ## Examples774 775 Example file: [deploy](./examples/deploy)776 49 unmodified lines